Class SmallMeanPoissonSampler

java.lang.Object
org.apache.commons.rng.sampling.distribution.SmallMeanPoissonSampler
All Implemented Interfaces:
DiscreteSampler, SharedStateDiscreteSampler, SharedStateSampler<SharedStateDiscreteSampler>

public class SmallMeanPoissonSampler extends Object implements SharedStateDiscreteSampler
Sampler for the Poisson distribution.
  • For small means, a Poisson process is simulated using uniform deviates, as described in
    Knuth (1969). Seminumerical Algorithms. The Art of Computer Programming, Volume 2. Chapter 3.4.1.F.3 Important integer-valued distributions: The Poisson distribution. Addison Wesley.
    The Poisson process (and hence, the returned value) is bounded by 1000 * mean.

This sampler is suitable for mean < 40. For large means, LargeMeanPoissonSampler should be used instead.

Sampling uses UniformRandomProvider.nextDouble() and requires on average mean + 1 deviates per sample.

Since:
1.1
  • Field Details

    • p0

      private final double p0
      Pre-compute Math.exp(-mean). Note: This is the probability of the Poisson sample P(n=0).
    • limit

      private final int limit
      Pre-compute 1000 * mean as the upper limit of the sample.
    • rng

      private final UniformRandomProvider rng
      Underlying source of randomness.
  • Constructor Details

    • SmallMeanPoissonSampler

      public SmallMeanPoissonSampler(UniformRandomProvider rng, double mean)
      Parameters:
      rng - Generator of uniformly distributed random numbers.
      mean - Mean.
      Throws:
      IllegalArgumentException - if mean <= 0 or Math.exp(-mean) == 0
    • SmallMeanPoissonSampler

      private SmallMeanPoissonSampler(UniformRandomProvider rng, SmallMeanPoissonSampler source)
      Parameters:
      rng - Generator of uniformly distributed random numbers.
      source - Source to copy.
  • Method Details