org.apache.commons.math3.distribution
Class AbstractRealDistribution
- java.lang.Object
-
- org.apache.commons.math3.distribution.AbstractRealDistribution
-
- All Implemented Interfaces:
- java.io.Serializable, RealDistribution
- Direct Known Subclasses:
- BetaDistribution, CauchyDistribution, ChiSquaredDistribution, ConstantRealDistribution, EmpiricalDistribution, EnumeratedRealDistribution, ExponentialDistribution, FDistribution, GammaDistribution, GumbelDistribution, LaplaceDistribution, LevyDistribution, LogisticDistribution, LogNormalDistribution, NakagamiDistribution, NormalDistribution, ParetoDistribution, TDistribution, TriangularDistribution, UniformRealDistribution, WeibullDistribution
public abstract class AbstractRealDistribution extends java.lang.Object implements RealDistribution, java.io.Serializable
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
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static doubleSOLVER_DEFAULT_ABSOLUTE_ACCURACYDefault accuracy.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description doublecumulativeProbability(double x0, double x1)Deprecated.As of 3.1 (to be removed in 4.0). Please useprobability(double,double)instead.doubleinverseCumulativeProbability(double p)Computes the quantile function of this distribution.doublelogDensity(double x)Returns the natural logarithm of the probability density function (PDF) of this distribution evaluated at the specified pointx.doubleprobability(double x)For a random variableXwhose values are distributed according to this distribution, this method returnsP(X = x).doubleprobability(double x0, double x1)For a random variableXwhose values are distributed according to this distribution, this method returnsP(x0 < X <= x1).voidreseedRandomGenerator(long seed)Reseed the random generator used to generate samples.doublesample()Generate a random value sampled from this distribution.double[]sample(int sampleSize)Generate a random sample from the distribution.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.math3.distribution.RealDistribution
cumulativeProbability, density, getNumericalMean, getNumericalVariance, getSupportLowerBound, getSupportUpperBound, isSupportConnected, isSupportLowerBoundInclusive, isSupportUpperBoundInclusive
-
-
-
-
Field Detail
-
SOLVER_DEFAULT_ABSOLUTE_ACCURACY
public static final double SOLVER_DEFAULT_ABSOLUTE_ACCURACY
Default accuracy.- See Also:
- Constant Field Values
-
-
Method Detail
-
cumulativeProbability
@Deprecated public double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeExceptionDeprecated. As of 3.1 (to be removed in 4.0). Please useprobability(double,double)instead.For a random variableXwhose values are distributed according to this distribution, this method returnsP(x0 < X <= x1). The default implementation uses the identityP(x0 < X <= x1) = P(X <= x1) - P(X <= x0)- Specified by:
cumulativeProbabilityin interfaceRealDistribution- Parameters:
x0- the exclusive lower boundx1- the inclusive upper bound- Returns:
- the probability that a random variable with this distribution
takes a value between
x0andx1, excluding the lower and including the upper endpoint - Throws:
NumberIsTooLargeException- ifx0 > x1
-
probability
public double probability(double x0, double x1)For a random variableXwhose values are distributed according to this distribution, this method returnsP(x0 < X <= x1).- Parameters:
x0- Lower bound (excluded).x1- Upper bound (included).- Returns:
- the probability that a random variable with this distribution
takes a value between
x0andx1, excluding the lower and including the upper endpoint. - Throws:
NumberIsTooLargeException- ifx0 > x1. The default implementation uses the identityP(x0 < X <= x1) = P(X <= x1) - P(X <= x0)- Since:
- 3.1
-
inverseCumulativeProbability
public double inverseCumulativeProbability(double p) throws OutOfRangeExceptionComputes the quantile function of this distribution. For a random variableXdistributed according to this distribution, the returned value isinf{x in R | P(X<=x) >= p}for0 < p <= 1,inf{x in R | P(X<=x) > 0}forp = 0.
RealDistribution.getSupportLowerBound()forp = 0,RealDistribution.getSupportUpperBound()forp = 1.
- Specified by:
inverseCumulativeProbabilityin interfaceRealDistribution- Parameters:
p- the cumulative probability- Returns:
- the smallest
p-quantile of this distribution (largest 0-quantile forp = 0) - Throws:
OutOfRangeException- ifp < 0orp > 1
-
reseedRandomGenerator
public void reseedRandomGenerator(long seed)
Reseed the random generator used to generate samples.- Specified by:
reseedRandomGeneratorin interfaceRealDistribution- Parameters:
seed- the new seed
-
sample
public double sample()
Generate a random value sampled from this distribution. The default implementation uses the inversion method.- Specified by:
samplein interfaceRealDistribution- Returns:
- a random value.
-
sample
public double[] sample(int sampleSize)
Generate a random sample from the distribution. The default implementation generates the sample by callingsample()in a loop.- Specified by:
samplein interfaceRealDistribution- Parameters:
sampleSize- the number of random values to generate- Returns:
- an array representing the random sample
-
probability
public double probability(double x)
For a random variableXwhose values are distributed according to this distribution, this method returnsP(X = x). In other words, this method represents the probability mass function (PMF) for the distribution.- Specified by:
probabilityin interfaceRealDistribution- Parameters:
x- the point at which the PMF is evaluated- Returns:
- zero.
- Since:
- 3.1
-
logDensity
public double logDensity(double x)
Returns the natural logarithm of the probability density function (PDF) of this distribution evaluated at the specified pointx. In general, the PDF is the derivative of theCDF. If the derivative does not exist atx, 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 ofRealDistribution.density(double). The default implementation simply computes the logarithm ofdensity(x).- Parameters:
x- the point at which the PDF is evaluated- Returns:
- the logarithm of the value of the probability density function at point
x
-
-
DMelt 3.0 © DataMelt by jWork.ORG