Class KempSmallMeanPoissonSampler

    • Field Detail

      • p0

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

        private final double mean
        The mean of the Poisson sample.
    • Constructor Detail

      • KempSmallMeanPoissonSampler

        private KempSmallMeanPoissonSampler​(UniformRandomProvider rng,
                                            double p0,
                                            double mean)
        Parameters:
        rng - Generator of uniformly distributed random numbers.
        p0 - Probability of the Poisson sample p(x=0).
        mean - Mean.
    • Method Detail

      • sample

        public int sample()
        Creates an int sample.
        Specified by:
        sample in interface DiscreteSampler
        Returns:
        a sample.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • of

        public static SharedStateDiscreteSampler of​(UniformRandomProvider rng,
                                                    double mean)
        Creates a new sampler for the Poisson distribution.
        Parameters:
        rng - Generator of uniformly distributed random numbers.
        mean - Mean of the distribution.
        Returns:
        the sampler
        Throws:
        java.lang.IllegalArgumentException - if mean <= 0 or Math.exp(-mean) == 0.