Implementation of an integer-valued EnumeratedDistribution.
Values with zero-probability are allowed but they do not extend the
support.
Duplicate values are allowed. Probabilities of duplicate values are combined
when computing cumulative probabilities and statistics.
| Modifier and Type | Field and Description |
|---|---|
| protected final EnumeratedDistribution | innerDistribution
|
| private static final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| public | EnumeratedIntegerDistribution(final int[]
array of random variable values. singletons, final double[] array of probabilities. probabilities)Create a discrete distribution using the given probability mass function definition. |
| public | EnumeratedIntegerDistribution(final RandomGenerator
random number generator. rng, final int[] array of random variable values. singletons, final double[] array of probabilities. probabilities)Create a discrete distribution using the given random number generator and probability mass function definition. |
| public | EnumeratedIntegerDistribution(final RandomGenerator
random number generator used for sampling rng, final int[] input dataset data)Create a discrete integer-valued distribution from the input data. |
| public | EnumeratedIntegerDistribution(final int[]
input dataset data)Create a discrete integer-valued distribution from the input data. |
| Modifier and Type | Method and Description |
|---|---|
| private static List | Returns: list of value/probability pairsvalues singletons, double[] probabilities probabilities)Create the list of Pairs representing the distribution from singletons and probabilities. |
| public double | cumulativeProbability(final int
the point at which the CDF is evaluated x)Implements org. For a random variable |
| public double | Returns: sum(singletons[i] * probabilities[i])Implements org. Use this method to get the numerical value of the mean of this distribution. |
| public double | Returns: sum((singletons[i] - mean) ^ 2 * probabilities[i])Implements org. Use this method to get the numerical value of the variance of this distribution. |
| public int | Returns: the lowest value with non-zero probability.Implements org. Access the lower bound of the support. |
| public int | Returns: the highest value with non-zero probability.Implements org. Access the upper bound of the support. |
| public boolean | Returns: trueImplements org. Use this method to get information about whether the support is connected, i.e. whether all integers between the lower and upper bound of the support are included in the support. |
| public double | probability(final int
the point at which the PMF is evaluated x)Implements org. For a random variable |
| public int | sample()
Overrides org. Implements org. Generate a random value sampled from this distribution. |
| innerDistribution | back to summary |
|---|---|
| protected final EnumeratedDistribution<Integer> innerDistribution
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serializable UID. | |
| EnumeratedIntegerDistribution | back to summary |
|---|---|
| public EnumeratedIntegerDistribution(final int[] singletons, final double[] probabilities) throws DimensionMismatchException, NotPositiveException, MathArithmeticException, NotFiniteNumberException, NotANumberException Create a discrete distribution using the given probability mass function definition. Note this constructor will implicitly create an instance of
| |
| EnumeratedIntegerDistribution | back to summary |
|---|---|
| public EnumeratedIntegerDistribution(final RandomGenerator rng, final int[] singletons, final double[] probabilities) throws DimensionMismatchException, NotPositiveException, MathArithmeticException, NotFiniteNumberException, NotANumberException Create a discrete distribution using the given random number generator and probability mass function definition.
| |
| EnumeratedIntegerDistribution | back to summary |
|---|---|
| public EnumeratedIntegerDistribution(final RandomGenerator rng, final int[] data) Create a discrete integer-valued distribution from the input data. Values are assigned mass based on their frequency.
| |
| EnumeratedIntegerDistribution | back to summary |
|---|---|
| public EnumeratedIntegerDistribution(final int[] data) Create a discrete integer-valued distribution from the input data. Values are assigned mass based on their frequency. For example, [0,1,1,2] as input creates a distribution with values 0, 1 and 2 having probability masses 0.25, 0.5 and 0.25 respectively,
| |
| createDistribution | back to summary |
|---|---|
| private static List Create the list of Pairs representing the distribution from singletons and probabilities. | |
| cumulativeProbability | back to summary |
|---|---|
| public double cumulativeProbability(final int x) Implements org. Doc from org. For a random variable
| |
| getNumericalMean | back to summary |
|---|---|
| public double getNumericalMean() Implements org. Doc from org. Use this method to get the numerical value of the mean of this distribution.
| |
| getNumericalVariance | back to summary |
|---|---|
| public double getNumericalVariance() Implements org. Doc from org. Use this method to get the numerical value of the variance of this distribution.
| |
| getSupportLowerBound | back to summary |
|---|---|
| public int getSupportLowerBound() Implements org. Doc from org. Access the lower bound of the support. This method must return the same
value as
| |
| getSupportUpperBound | back to summary |
|---|---|
| public int getSupportUpperBound() Implements org. Doc from org. Access the upper bound of the support. This method must return the same
value as
| |
| isSupportConnected | back to summary |
|---|---|
| public boolean isSupportConnected() Implements org. Doc from org. Use this method to get information about whether the support is connected, i.e. whether all integers between the lower and upper bound of the support are included in the support. The support of this distribution is connected.
| |
| probability | back to summary |
|---|---|
| public double probability(final int x) Implements org. Doc from org. For a random variable
| |
| sample | back to summary |
|---|---|
| public int sample() Overrides org. Implements org. Doc from org. Generate a random value sampled from this distribution. The default implementation uses the inversion method.
| |