public final class AliasMethod
extends java.lang.Object
Constructor and Description |
---|
AliasMethod(double[] probabilities)
Constructs a new AliasMethod to sample from a discrete distribution and
hand back outcomes based on the probability distribution.
|
AliasMethod(double[] probabilities,
java.util.SplittableRandom random)
Constructs a new AliasMethod to sample from a discrete distribution and
hand back outcomes based on the probability distribution.
|
Modifier and Type | Method and Description |
---|---|
int |
getProbabilitiesSize() |
int |
next()
Samples a value from the underlying distribution.
|
public AliasMethod(double[] probabilities)
Given as input a list of probabilities corresponding to outcomes 0, 1, ..., n - 1, this constructor creates the probability and alias tables needed to efficiently sample from this distribution.
probabilities
- The list of probabilities.public AliasMethod(double[] probabilities, java.util.SplittableRandom random)
Given as input a list of probabilities corresponding to outcomes 0, 1, ..., n - 1, along with the random number generator that should be used as the underlying generator, this constructor creates the probability and alias tables needed to efficiently sample from this distribution.
probabilities
- The list of probabilities.random2
- The random number generator