PeterO.RandomGenerator.Poisson C# (CSharp) Method

Poisson() public method

Generates a random integer such that the average of random numbers approaches the given mean number when this method is called repeatedly with the same mean.
public Poisson ( double mean ) : int
mean double The expected mean of the random numbers.
return int
        public int Poisson(double mean)
        {
            if (mean < 0) {
            throw new ArgumentException("mean (" + mean +
              ") is less than 0");
              }
              double l = Math.Exp(-mean);
              var k = 0;
              double p = 0;
              do {
            ++k;
            p *= this.Uniform();
              } while (p > l);
              return k - 1;
        }