Serializable, IntegerDistributionBinomialDistribution, EnumeratedIntegerDistribution, GeometricDistribution, HypergeometricDistribution, PascalDistribution, PoissonDistribution, UniformIntegerDistribution, ZipfDistributionpublic abstract class AbstractIntegerDistribution extends Object implements IntegerDistribution, Serializable
IntegerDistribution.Sampler| Constructor | Description |
|---|---|
AbstractIntegerDistribution() |
| Modifier and Type | Method | Description |
|---|---|---|
IntegerDistribution.Sampler |
createSampler(org.apache.commons.rng.UniformRandomProvider rng) |
Creates a sampler.
|
int |
inverseCumulativeProbability(double p) |
Computes the quantile function of this distribution.
|
double |
logProbability(int x) |
For a random variable
X whose values are distributed according to
this distribution, this method returns log(P(X = x)), where
log is the natural logarithm. |
double |
probability(int x0,
int x1) |
For a random variable
X whose values are distributed according
to this distribution, this method returns P(x0 < X <= x1). |
static int[] |
sample(int n,
IntegerDistribution.Sampler sampler) |
Utility function for allocating an array and filling it with
n
samples generated by the given sampler. |
protected int |
solveInverseCumulativeProbability(double p,
int lower,
int upper) |
This is a utility function used by
inverseCumulativeProbability(double). |
cumulativeProbability, getNumericalMean, getNumericalVariance, getSupportLowerBound, getSupportUpperBound, isSupportConnected, probabilitypublic double probability(int x0,
int x1)
throws NumberIsTooLargeException
X whose values are distributed according
to this distribution, this method returns P(x0 < X <= x1).
The default implementation uses the identity
P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)
probability in interface IntegerDistributionx0 - the exclusive lower boundx1 - the inclusive upper boundx0 and x1,
excluding the lower and including the upper endpointNumberIsTooLargeException - if x0 > x1public int inverseCumulativeProbability(double p)
throws OutOfRangeException
X distributed according to this distribution,
the returned value is
inf{x in Z | P(X<=x) >= p} for 0 < p <= 1,inf{x in Z | P(X<=x) > 0} for p = 0.int,
then Integer.MIN_VALUE or Integer.MAX_VALUE is returned.
The default implementation returns
IntegerDistribution.getSupportLowerBound() for p = 0,IntegerDistribution.getSupportUpperBound() for p = 1, andsolveInverseCumulativeProbability(double, int, int) for
0 < p < 1.inverseCumulativeProbability in interface IntegerDistributionp - the cumulative probabilityp-quantile of this distribution
(largest 0-quantile for p = 0)OutOfRangeException - if p < 0 or p > 1protected int solveInverseCumulativeProbability(double p,
int lower,
int upper)
inverseCumulativeProbability(double). It assumes 0 < p < 1 and
that the inverse cumulative probability lies in the bracket
(lower, upper]. The implementation does simple bisection to find the
smallest p-quantile inf{x in Z | P(X<=x) >= p}.p - the cumulative probabilitylower - a value satisfying cumulativeProbability(lower) < pupper - a value satisfying p <= cumulativeProbability(upper)p-quantile of this distributionpublic double logProbability(int x)
X whose values are distributed according to
this distribution, this method returns log(P(X = x)), where
log is the natural logarithm. In other words, this method
represents the logarithm of the probability mass function (PMF) for the
distribution. Note that due to the floating point precision and
under/overflow issues, this method will for some distributions be more
precise and faster than computing the logarithm of
IntegerDistribution.probability(int).
The default implementation simply computes the logarithm of probability(x).
logProbability in interface IntegerDistributionx - the point at which the PMF is evaluatedxpublic static int[] sample(int n,
IntegerDistribution.Sampler sampler)
n
samples generated by the given sampler.n - Number of samples.sampler - Sampler.n.public IntegerDistribution.Sampler createSampler(org.apache.commons.rng.UniformRandomProvider rng)
createSampler in interface IntegerDistributionrng - Generator of uniformly distributed numbers.Copyright © 2003–2017 The Apache Software Foundation. All rights reserved.