public class AliasMethodSampler extends Object
The implementation is described in the paper: Michael D. Vose. A Linear Algorithm for Generating Random Numbers with a Given Distribution. IEEE Transactions on Software Engineering, 17(9):972--975, 1991.
Initialization takes O(n) where n is the number of items. Sampling takes O(1).
| Constructor and Description |
|---|
AliasMethodSampler(double[] p)
Constructor
|
AliasMethodSampler(double[] p,
long seed)
Constructor
|
AliasMethodSampler(double[] p,
Random rng)
Constructor
|
AliasMethodSampler(double[] p,
Random rng,
double epsilon)
Constructor
|
public AliasMethodSampler(double[] p)
p - the probability distribution where position i of the array is Prob(X=i)IllegalArgumentException - in case of a non-valid probability distributionpublic AliasMethodSampler(double[] p,
long seed)
p - the probability distribution where position i of the array is Prob(X=i)seed - seed to use for the random number generatorpublic AliasMethodSampler(double[] p,
Random rng)
p - the probability distribution where position i of the array is Prob(X=i)rng - the random number generatorIllegalArgumentException - in case of a non-valid probability distributionpublic AliasMethodSampler(double[] p,
Random rng,
double epsilon)
p - the probability distribution where position i of the array is Prob(X=i)rng - the random number generatorepsilon - tolerance used when comparing floating-point valuesIllegalArgumentException - in case of a non-valid probability distributionCopyright © 2017. All rights reserved.