public static final class MarsagliaTsangWangDiscreteSampler.Binomial extends Object
| Modifier and Type | Method and Description |
|---|---|
static SharedStateDiscreteSampler |
of(UniformRandomProvider rng,
int trials,
double probabilityOfSuccess)
Creates a sampler for the Binomial distribution.
|
public static SharedStateDiscreteSampler of(UniformRandomProvider rng, int trials, double probabilityOfSuccess)
Any probability less than 2-31 will not be observed in samples.
Storage requirements depend on the tabulated probability values. Example storage requirements are listed below (in kB).
p
trials 0.5 0.1 0.01 0.001
4 0.06 0.63 0.44 0.44
16 0.69 1.14 0.76 0.44
64 4.73 2.40 1.14 0.51
256 8.63 5.17 1.89 0.82
1024 31.12 9.45 3.34 0.89
The method requires that the Binomial distribution probability at x=0 can be computed.
This will fail when (1 - p)^trials == 0 which requires trials to be large
and/or p to be small. In this case an exception is raised.
rng - Generator of uniformly distributed random numbers.trials - Number of trials.probabilityOfSuccess - Probability of success (p).IllegalArgumentException - if trials < 0 or trials >= 2^16,
p is not in the range [0-1], or the probability distribution cannot
be computed.Copyright © 2016–2022 The Apache Software Foundation. All rights reserved.