public static final class MarsagliaTsangWangDiscreteSampler.Enumerated extends java.lang.Object
n
values each with an
associated probability.
The samples corresponding to each probability are assumed to be a natural sequence
starting at zero.Modifier and Type | Method | Description |
---|---|---|
static SharedStateDiscreteSampler |
of(org.apache.commons.rng.UniformRandomProvider rng,
double[] probabilities) |
Creates a sampler for an enumerated distribution of
n values each with an
associated probability. |
public static SharedStateDiscreteSampler of(org.apache.commons.rng.UniformRandomProvider rng, double[] probabilities)
n
values each with an
associated probability.
The probabilities will be normalised using their sum. The only requirement is the sum is positive.
The sum of the probabilities is normalised to 230. Note that probabilities are adjusted to the nearest 1-30 due to round-off during the normalisation conversion. Consequently any probability less than 2-31 will not be observed in samples.
rng
- Generator of uniformly distributed random numbers.probabilities
- The list of probabilities.java.lang.IllegalArgumentException
- if probabilities
is null or empty, a
probability is negative, infinite or NaN
, or the sum of all
probabilities is not strictly positive.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.