Serializable, RealDistributionBetaDistribution, CauchyDistribution, ChiSquaredDistribution, ConstantRealDistribution, EmpiricalDistribution, EnumeratedRealDistribution, ExponentialDistribution, FDistribution, GammaDistribution, GumbelDistribution, LaplaceDistribution, LevyDistribution, LogisticDistribution, LogNormalDistribution, NakagamiDistribution, NormalDistribution, ParetoDistribution, TDistribution, TriangularDistribution, UniformRealDistribution, WeibullDistributionpublic abstract class AbstractRealDistribution extends Object implements RealDistribution, Serializable
This base class provides a default factory method for creating
a sampler instance that uses the
inversion method for generating random samples that follow the
distribution.
RealDistribution.Sampler| Modifier and Type | Field | Description |
|---|---|---|
static double |
SOLVER_DEFAULT_ABSOLUTE_ACCURACY |
Default absolute accuracy for inverse cumulative computation.
|
| Constructor | Description |
|---|---|
AbstractRealDistribution() |
| Modifier and Type | Method | Description |
|---|---|---|
RealDistribution.Sampler |
createSampler(org.apache.commons.rng.UniformRandomProvider rng) |
Creates a sampler.
|
protected double |
getSolverAbsoluteAccuracy() |
Returns the solver absolute accuracy for inverse cumulative computation.
|
double |
inverseCumulativeProbability(double p) |
Computes the quantile function of this distribution.
|
double |
logDensity(double x) |
Returns the natural logarithm of the probability density function
(PDF) of this distribution evaluated at the specified point
x. |
double |
probability(double x) |
For a random variable
X whose values are distributed according
to this distribution, this method returns P(X = x). |
double |
probability(double x0,
double x1) |
For a random variable
X whose values are distributed according
to this distribution, this method returns P(x0 < X <= x1). |
static double[] |
sample(int n,
RealDistribution.Sampler sampler) |
Utility function for allocating an array and filling it with
n
samples generated by the given sampler. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcumulativeProbability, density, getNumericalMean, getNumericalVariance, getSupportLowerBound, getSupportUpperBound, isSupportConnectedpublic static final double SOLVER_DEFAULT_ABSOLUTE_ACCURACY
public double probability(double x0,
double x1)
X whose values are distributed according
to this distribution, this method returns P(x0 < X <= x1).probability in interface RealDistributionx0 - Lower bound (excluded).x1 - Upper bound (included).x0 and x1, excluding the lower
and including the upper endpoint.NumberIsTooLargeException - if x0 > x1.
The default implementation uses the identity
P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)public double inverseCumulativeProbability(double p)
throws OutOfRangeException
X distributed according to this distribution, the
returned value is
inf{x in R | P(X<=x) >= p} for 0 < p <= 1,inf{x in R | P(X<=x) > 0} for p = 0.RealDistribution.getSupportLowerBound() for p = 0,RealDistribution.getSupportUpperBound() for p = 1.inverseCumulativeProbability in interface RealDistributionp - the cumulative probabilityp-quantile of this distribution
(largest 0-quantile for p = 0)OutOfRangeException - if p < 0 or p > 1protected double getSolverAbsoluteAccuracy()
public double probability(double x)
X whose values are distributed according
to this distribution, this method returns P(X = x). In other
words, this method represents the probability mass function (PMF)
for the distribution.probability in interface RealDistributionx - the point at which the PMF is evaluatedpublic double logDensity(double x)
x.
In general, the PDF is the derivative of the CDF.
If the derivative does not exist at x, then an appropriate replacement
should be returned, e.g. Double.POSITIVE_INFINITY, Double.NaN,
or the limit inferior or limit superior of the difference quotient. 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
RealDistribution.density(double).
The default implementation simply computes the logarithm of density(x).
logDensity in interface RealDistributionx - the point at which the PDF is evaluatedxpublic static double[] sample(int n,
RealDistribution.Sampler sampler)
n
samples generated by the given sampler.n - Number of samples.sampler - Sampler.n.public RealDistribution.Sampler createSampler(org.apache.commons.rng.UniformRandomProvider rng)
createSampler in interface RealDistributionrng - Generator of uniformly distributed numbers.Copyright © 2003–2017 The Apache Software Foundation. All rights reserved.