Top Description Fields Constructors Methods
org.apache.commons.math3.distribution

public abstract Class AbstractRealDistribution

extends Object
implements RealDistribution, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.math3.distribution.RealDistribution
Known Direct Subclasses
org.apache.commons.math3.distribution.BetaDistribution, org.apache.commons.math3.distribution.CauchyDistribution, org.apache.commons.math3.distribution.ChiSquaredDistribution, org.apache.commons.math3.distribution.ConstantRealDistribution, org.apache.commons.math3.distribution.EnumeratedRealDistribution, org.apache.commons.math3.distribution.ExponentialDistribution, org.apache.commons.math3.distribution.FDistribution, org.apache.commons.math3.distribution.GammaDistribution, org.apache.commons.math3.distribution.GumbelDistribution, org.apache.commons.math3.distribution.LaplaceDistribution, org.apache.commons.math3.distribution.LevyDistribution, org.apache.commons.math3.distribution.LogisticDistribution, org.apache.commons.math3.distribution.LogNormalDistribution, org.apache.commons.math3.distribution.NakagamiDistribution, org.apache.commons.math3.distribution.NormalDistribution, org.apache.commons.math3.distribution.ParetoDistribution, org.apache.commons.math3.distribution.TDistribution, org.apache.commons.math3.distribution.TriangularDistribution, org.apache.commons.math3.distribution.UniformRealDistribution, org.apache.commons.math3.distribution.WeibullDistribution, org.apache.commons.math3.random.EmpiricalDistribution
Imports
java.io.Serializable, org.apache.commons.math3.analysis.UnivariateFunction, org.apache.commons.math3.analysis.solvers.UnivariateSolverUtils, org.apache.commons.math3.exception.NotStrictlyPositiveException, .NumberIsTooLargeException, .OutOfRangeException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.random.RandomGenerator, org.apache.commons.math3.util.FastMath

Base class for probability distributions on the reals. Default implementations are provided for some of the methods that do not vary from distribution to distribution.
Since
3.0

Field Summary

Modifier and TypeField and Description
protected final RandomGenerator
random

RNG instance used to generate samples from the distribution.

protected RandomDataImpl
randomData

Deprecated As of 3.1, to be removed in 4.0. Please use the random instance variable instead.
RandomData instance used to generate samples from the distribution.
private static final long
serialVersionUID

Serializable version identifier

public static final double
private double
solverAbsoluteAccuracy

Solver absolute accuracy for inverse cumulative computation

Constructor Summary

AccessConstructor and Description
protected
AbstractRealDistribution()
Deprecated As of 3.1, to be removed in 4.0.

protected
AbstractRealDistribution(RandomGenerator
Random number generator.
rng
)

Method Summary

Modifier and TypeMethod and Description
public double
cumulativeProbability(double
the exclusive lower bound
x0
,
double
the inclusive upper bound
x1
)

Implements org.apache.commons.math3.distribution.RealDistribution.cumulativeProbability.

Deprecated As of 3.1 (to be removed in 4.0). Please use probability(double, double) instead.

For a random variable X whose values are distributed according to this distribution, this method returns P(x0 < X <= x1).

protected double

Returns:

the maximum absolute error in inverse cumulative probability estimates
getSolverAbsoluteAccuracy
()

Returns the solver absolute accuracy for inverse cumulative computation.

public double
inverseCumulativeProbability(final double
the cumulative probability
p
)

Implements org.apache.commons.math3.distribution.RealDistribution.inverseCumulativeProbability.

Computes the quantile function of this distribution.

public double

Returns:

the logarithm of the value of the probability density function at point x
logDensity
(double
the point at which the PDF is evaluated
x
)

Returns the natural logarithm of the probability density function (PDF) of this distribution evaluated at the specified point x.

public double

Returns:

the probability that a random variable with this distribution takes a value between x0 and x1, excluding the lower and including the upper endpoint.
probability
(double
Lower bound (excluded).
x0
,
double
Upper bound (included).
x1
)

For a random variable X whose values are distributed according to this distribution, this method returns P(x0 < X <= x1).

public double

Returns:

zero.
probability
(double
the point at which the PMF is evaluated
x
)

Implements org.apache.commons.math3.distribution.RealDistribution.probability.

For a random variable X whose values are distributed according to this distribution, this method returns P(X = x).

public void
reseedRandomGenerator(long
the new seed
seed
)

Implements org.apache.commons.math3.distribution.RealDistribution.reseedRandomGenerator.

Reseed the random generator used to generate samples.

public double
sample()

Implements org.apache.commons.math3.distribution.RealDistribution.sample.

Generate a random value sampled from this distribution.

public double[]
sample(int
the number of random values to generate
sampleSize
)

Implements org.apache.commons.math3.distribution.RealDistribution.sample.

Generate a random sample from the distribution.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

randomback to summary
protected final RandomGenerator random

RNG instance used to generate samples from the distribution.

Since
3.1
randomDataback to summary
protected RandomDataImpl randomData

Deprecated

As of 3.1, to be removed in 4.0. Please use the random instance variable instead.

RandomData instance used to generate samples from the distribution.

Annotations
@Deprecated
serialVersionUIDback to summary
private static final long serialVersionUID

Serializable version identifier

SOLVER_DEFAULT_ABSOLUTE_ACCURACYback to summary
public static final double SOLVER_DEFAULT_ABSOLUTE_ACCURACY

Default accuracy.

solverAbsoluteAccuracyback to summary
private double solverAbsoluteAccuracy

Solver absolute accuracy for inverse cumulative computation

Constructor Detail

AbstractRealDistributionback to summary
protected AbstractRealDistribution()

Deprecated

As of 3.1, to be removed in 4.0. Please use AbstractRealDistribution(RandomGenerator) instead.

Annotations
@Deprecated
AbstractRealDistributionback to summary
protected AbstractRealDistribution(RandomGenerator rng)
Parameters
rng:RandomGenerator

Random number generator.

Since
3.1

Method Detail

cumulativeProbabilityback to summary
public double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeException

Implements org.apache.commons.math3.distribution.RealDistribution.cumulativeProbability.

Doc from org.apache.commons.math3.distribution.RealDistribution.cumulativeProbability.

Deprecated

As of 3.1 (to be removed in 4.0). Please use probability(double, double) instead.

For a random variable 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)

Parameters
x0:double

the exclusive lower bound

x1:double

the inclusive upper bound

Returns:double

the probability that a random variable with this distribution takes a value between x0 and x1, excluding the lower and including the upper endpoint

Annotations
@Deprecated
Exceptions
NumberIsTooLargeException:
if x0 > x1
getSolverAbsoluteAccuracyback to summary
protected double getSolverAbsoluteAccuracy()

Returns the solver absolute accuracy for inverse cumulative computation. You can override this method in order to use a Brent solver with an absolute accuracy different from the default.

Returns:double

the maximum absolute error in inverse cumulative probability estimates

inverseCumulativeProbabilityback to summary
public double inverseCumulativeProbability(final double p) throws OutOfRangeException

Implements org.apache.commons.math3.distribution.RealDistribution.inverseCumulativeProbability.

Doc from org.apache.commons.math3.distribution.RealDistribution.inverseCumulativeProbability.

Computes the quantile function of this distribution. For a random variable 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.
The default implementation returns
Parameters
p:double

the cumulative probability

Returns:double

the smallest p-quantile of this distribution (largest 0-quantile for p = 0)

Exceptions
OutOfRangeException:
if p < 0 or p > 1
logDensityback to summary
public double logDensity(double x)

Returns the natural logarithm of the probability density function (PDF) of this distribution evaluated at the specified point 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 density(double). The default implementation simply computes the logarithm of density(x).

Parameters
x:double

the point at which the PDF is evaluated

Returns:double

the logarithm of the value of the probability density function at point x

probabilityback to summary
public 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).

Parameters
x0:double

Lower bound (excluded).

x1:double

Upper bound (included).

Returns:double

the probability that a random variable with this distribution takes a value between x0 and x1, excluding the lower and including the upper endpoint.

Exceptions
NumberIsTooLargeException:
if x0 > x1. The default implementation uses the identity P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)
Since
3.1
probabilityback to summary
public double probability(double x)

Implements org.apache.commons.math3.distribution.RealDistribution.probability.

Doc from org.apache.commons.math3.distribution.RealDistribution.probability.

For a random variable 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.

Parameters
x:double

the point at which the PMF is evaluated

Returns:double

zero.

Since
3.1
reseedRandomGeneratorback to summary
public void reseedRandomGenerator(long seed)

Implements org.apache.commons.math3.distribution.RealDistribution.reseedRandomGenerator.

Doc from org.apache.commons.math3.distribution.RealDistribution.reseedRandomGenerator.

Reseed the random generator used to generate samples.

Parameters
seed:long

the new seed

sampleback to summary
public double sample()

Implements org.apache.commons.math3.distribution.RealDistribution.sample.

Doc from org.apache.commons.math3.distribution.RealDistribution.sample.

Generate a random value sampled from this distribution. The default implementation uses the inversion method.

Returns:double

a random value.

sampleback to summary
public double[] sample(int sampleSize)

Implements org.apache.commons.math3.distribution.RealDistribution.sample.

Doc from org.apache.commons.math3.distribution.RealDistribution.sample.

Generate a random sample from the distribution. The default implementation generates the sample by calling sample() in a loop.

Parameters
sampleSize:int

the number of random values to generate

Returns:double[]

an array representing the random sample