Class TDistribution.NormalTDistribution
- java.lang.Object
-
- org.apache.commons.statistics.distribution.AbstractContinuousDistribution
-
- org.apache.commons.statistics.distribution.TDistribution
-
- org.apache.commons.statistics.distribution.TDistribution.NormalTDistribution
-
- All Implemented Interfaces:
ContinuousDistribution
- Enclosing class:
- TDistribution
private static class TDistribution.NormalTDistribution extends TDistribution
Specialisation of the T-distribution used when there are infinite degrees of freedom. In this case the distribution matches a normal distribution. This is used when the variance is not different from 1.0.This delegates all methods to the standard normal distribution. Instances are allowed to provide access to the degrees of freedom used during construction.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.commons.statistics.distribution.ContinuousDistribution
ContinuousDistribution.Sampler
-
-
Field Summary
Fields Modifier and Type Field Description private static NormalDistributionSTANDARD_NORMALA standard normal distribution used for calculations.
-
Constructor Summary
Constructors Constructor Description NormalTDistribution(double degreesOfFreedom)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContinuousDistribution.SamplercreateSampler(org.apache.commons.rng.UniformRandomProvider rng)Creates a sampler.doublecumulativeProbability(double x)For a random variableXwhose values are distributed according to this distribution, this method returnsP(X <= x).doubledensity(double x)Returns the probability density function (PDF) of this distribution evaluated at the specified pointx.doublegetMean()Gets the mean of this distribution.doublegetVariance()Gets the variance of this distribution.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 org.apache.commons.statistics.distribution.TDistribution
getDegreesOfFreedom, getSupportLowerBound, getSupportUpperBound, inverseSurvivalProbability, of, survivalProbability
-
Methods inherited from class org.apache.commons.statistics.distribution.AbstractContinuousDistribution
getMedian, isSupportConnected
-
-
-
-
Field Detail
-
STANDARD_NORMAL
private static final NormalDistribution STANDARD_NORMAL
A standard normal distribution used for calculations. This is immutable and thread-safe and can be used across instances.
-
-
Method Detail
-
density
public double density(double x)
Description copied from interface:ContinuousDistributionReturns the probability density function (PDF) of this distribution evaluated at the specified pointx. In general, the PDF is the derivative of the CDF. 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.- Parameters:
x- Point at which the PDF is evaluated.- Returns:
- the value of the probability density function at
x.
-
probability
public double probability(double x0, double x1)Description copied from class:AbstractContinuousDistributionFor 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:
probabilityin interfaceContinuousDistribution- Overrides:
probabilityin classAbstractContinuousDistribution- Parameters:
x0- Lower bound (exclusive).x1- Upper bound (inclusive).- Returns:
- the probability that a random variable with this distribution
takes a value between
x0andx1, excluding the lower and including the upper endpoint.
-
logDensity
public double logDensity(double x)
Description copied from interface:ContinuousDistributionReturns the natural logarithm of the probability density function (PDF) of this distribution evaluated at the specified pointx.- Parameters:
x- Point at which the PDF is evaluated.- Returns:
- the logarithm of the value of the probability density function
at
x.
-
cumulativeProbability
public double cumulativeProbability(double x)
Description copied from interface:ContinuousDistributionFor a random variableXwhose values are distributed according to this distribution, this method returnsP(X <= x). In other words, this method represents the (cumulative) distribution function (CDF) for this distribution.- Parameters:
x- Point at which the CDF is evaluated.- Returns:
- the probability that a random variable with this
distribution takes a value less than or equal to
x.
-
inverseCumulativeProbability
public double inverseCumulativeProbability(double p)
Description copied from class:AbstractContinuousDistributionComputes the quantile function of this distribution. For a random variableXdistributed according to this distribution, the returned value is:\[ x = \begin{cases} \inf \{ x \in \mathbb R : P(X \le x) \ge p\} & \text{for } 0 \lt p \le 1 \\ \inf \{ x \in \mathbb R : P(X \le x) \gt 0 \} & \text{for } p = 0 \end{cases} \]
The default implementation returns:
ContinuousDistribution.getSupportLowerBound()forp = 0,ContinuousDistribution.getSupportUpperBound()forp = 1, or- the result of a search for a root between the lower and upper bound using
cumulativeProbability(x) - p. The bounds may be bracketed for efficiency.
- Specified by:
inverseCumulativeProbabilityin interfaceContinuousDistribution- Overrides:
inverseCumulativeProbabilityin classAbstractContinuousDistribution- Parameters:
p- Cumulative probability.- Returns:
- the smallest
p-quantile of this distribution (largest 0-quantile forp = 0).
-
getMean
public double getMean()
Description copied from class:TDistributionGets the mean of this distribution.For degrees of freedom parameter \( v \), the mean is:
\[ \mathbb{E}[X] = \begin{cases} 0 & \text{for } v \gt 1 \\ \text{undefined} & \text{otherwise} \end{cases} \]
- Specified by:
getMeanin interfaceContinuousDistribution- Specified by:
getMeanin classTDistribution- Returns:
- the mean, or
NaNif it is not defined.
-
getVariance
public double getVariance()
Description copied from class:TDistributionGets the variance of this distribution.For degrees of freedom parameter \( v \), the variance is:
\[ \operatorname{var}[X] = \begin{cases} \frac{v}{v - 2} & \text{for } v \gt 2 \\ \infty & \text{for } 1 \lt v \le 2 \\ \text{undefined} & \text{otherwise} \end{cases} \]
- Specified by:
getVariancein interfaceContinuousDistribution- Specified by:
getVariancein classTDistribution- Returns:
- the variance, or
NaNif it is not defined.
-
createSampler
public ContinuousDistribution.Sampler createSampler(org.apache.commons.rng.UniformRandomProvider rng)
Description copied from class:AbstractContinuousDistributionCreates a sampler.- Specified by:
createSamplerin interfaceContinuousDistribution- Overrides:
createSamplerin classAbstractContinuousDistribution- Parameters:
rng- Generator of uniformly distributed numbers.- Returns:
- a sampler that produces random numbers according this distribution.
-
-