Class LargeMeanPoissonSampler
- java.lang.Object
-
- org.apache.commons.rng.sampling.distribution.LargeMeanPoissonSampler
-
- All Implemented Interfaces:
DiscreteSampler
,SharedStateDiscreteSampler
,SharedStateSampler<SharedStateDiscreteSampler>
public class LargeMeanPoissonSampler extends Object implements SharedStateDiscreteSampler
Sampler for the Poisson distribution.-
For large means, we use the rejection algorithm described in
Devroye, Luc. (1981).The Computer Generation of Poisson Random Variables
Computing vol. 26 pp. 197-207.
This sampler is suitable for
mean >= 40
.Sampling uses:
- Since:
- 1.1
-
-
Constructor Summary
Constructors Constructor Description LargeMeanPoissonSampler(UniformRandomProvider rng, double mean)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SharedStateDiscreteSampler
of(UniformRandomProvider rng, double mean)
Creates a new Poisson distribution sampler.int
sample()
Creates a sample.String
toString()
SharedStateDiscreteSampler
withUniformRandomProvider(UniformRandomProvider rng)
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.
-
-
-
Constructor Detail
-
LargeMeanPoissonSampler
public LargeMeanPoissonSampler(UniformRandomProvider rng, double mean)
- Parameters:
rng
- Generator of uniformly distributed random numbers.mean
- Mean.- Throws:
IllegalArgumentException
- ifmean < 1
ormean > 0.5 *
Integer.MAX_VALUE
.
-
-
Method Detail
-
sample
public int sample()
Creates a sample.- Specified by:
sample
in interfaceDiscreteSampler
- Returns:
- a sample.
-
withUniformRandomProvider
public SharedStateDiscreteSampler withUniformRandomProvider(UniformRandomProvider rng)
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.- Specified by:
withUniformRandomProvider
in interfaceSharedStateSampler<SharedStateDiscreteSampler>
- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
- Since:
- 1.3
-
of
public static SharedStateDiscreteSampler of(UniformRandomProvider rng, double mean)
Creates a new Poisson distribution sampler.- Parameters:
rng
- Generator of uniformly distributed random numbers.mean
- Mean.- Returns:
- the sampler
- Throws:
IllegalArgumentException
- ifmean < 1
ormean > 0.5 *
Integer.MAX_VALUE
.- Since:
- 1.3
-
-