Class AbstractRealDistribution
- java.lang.Object
-
- org.hipparchus.distribution.continuous.AbstractRealDistribution
-
- All Implemented Interfaces:
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 Object implements RealDistribution, 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.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static doubleDEFAULT_SOLVER_ABSOLUTE_ACCURACYDefault absolute accuracy for inverse cumulative computation.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractRealDistribution()Create a real distribution with default solver absolute accuracy.protectedAbstractRealDistribution(double solverAbsoluteAccuracy)Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected doublegetSolverAbsoluteAccuracy()Returns the solver absolute accuracy for inverse cumulative computation.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 x0, double x1)For a random variableXwhose values are distributed according to this distribution, this method returnsP(x0 < X <= x1).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hipparchus.distribution.RealDistribution
cumulativeProbability, density, getNumericalMean, getNumericalVariance, getSupportLowerBound, getSupportUpperBound, isSupportConnected
-
-
-
-
Field Detail
-
DEFAULT_SOLVER_ABSOLUTE_ACCURACY
protected static final double DEFAULT_SOLVER_ABSOLUTE_ACCURACY
Default absolute accuracy for inverse cumulative computation.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractRealDistribution
protected AbstractRealDistribution(double solverAbsoluteAccuracy)
Simple constructor.- Parameters:
solverAbsoluteAccuracy- the absolute accuracy to use when computing the inverse cumulative probability.
-
AbstractRealDistribution
protected AbstractRealDistribution()
Create a real distribution with default solver absolute accuracy.
-
-
Method Detail
-
probability
public double probability(double x0, double x1) throws MathIllegalArgumentExceptionFor a random variableXwhose values are distributed according to this distribution, this method returnsP(x0 < X <= x1).- Specified by:
probabilityin interfaceRealDistribution- 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:
MathIllegalArgumentException- ifx0 > x1. The default implementation uses the identityP(x0 < X <= x1) = P(X <= x1) - P(X <= x0)
-
inverseCumulativeProbability
public double inverseCumulativeProbability(double p) throws MathIllegalArgumentExceptionComputes 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:
MathIllegalArgumentException- ifp < 0orp > 1
-
getSolverAbsoluteAccuracy
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:
- the maximum absolute error in inverse cumulative probability estimates
-
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 of
density(x).- Specified by:
logDensityin interfaceRealDistribution- Parameters:
x- the point at which the PDF is evaluated- Returns:
- the logarithm of the value of the probability density function at point
x
-
-