Class NonCentralChiSquaredDistribution
- java.lang.Object
-
- com.opengamma.strata.math.impl.statistics.distribution.NonCentralChiSquaredDistribution
-
- All Implemented Interfaces:
ProbabilityDistribution<Double>
public class NonCentralChiSquaredDistribution extends Object implements ProbabilityDistribution<Double>
The non-central chi-squared distribution is a continuous probability distribution with probability density function $$ \begin{align*} f_r(x) = \frac{e^-\frac{x + \lambda}{2}x^{\frac{r}{2} - 1}}{2^{\frac{r}{2}}}\sum_{k=0}^\infty \frac{(\lambda k)^k}{2^{2k}k!\Gamma(k + \frac{r}{2})} \end{align*} $$ where $r$ is the number of degrees of freedom, $\lambda$ is the non-centrality parameter and $\Gamma$ is the Gamma function (GammaFunction
).For the case where $r + \lambda > 2000$, the implementation of the cdf is taken from "An Approximation for the Noncentral Chi-Squared Distribution", Fraser et al. (link). Otherwise, the algorithm is taken from "Computing the Non-Central Chi-Squared Distribution Function", Ding.
-
-
Constructor Summary
Constructors Constructor Description NonCentralChiSquaredDistribution(double degrees, double nonCentrality)
Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
double
getCDF(Double x)
Returns the cumulative distribution function for a valuedouble
getDegrees()
Gets the number of degrees of freedom.double
getInverseCDF(Double p)
Given a probability, return the value that returns this cdfdouble
getNonCentrality()
Gets the non-centrality parameter.double
getPDF(Double x)
Return the probability density function for a valueint
hashCode()
double
nextRandom()
-
-
-
Method Detail
-
getCDF
public double getCDF(Double x)
Returns the cumulative distribution function for a value- Specified by:
getCDF
in interfaceProbabilityDistribution<Double>
- Parameters:
x
- The value, not null- Returns:
- The cdf
-
getInverseCDF
public double getInverseCDF(Double p)
Given a probability, return the value that returns this cdf- Specified by:
getInverseCDF
in interfaceProbabilityDistribution<Double>
- Parameters:
p
- The probability, not null. $0 \geq p \geq 1$- Returns:
- Not supported
- Throws:
UnsupportedOperationException
- always
-
getPDF
public double getPDF(Double x)
Return the probability density function for a value- Specified by:
getPDF
in interfaceProbabilityDistribution<Double>
- Parameters:
x
- The value, not null- Returns:
- Not supported
- Throws:
UnsupportedOperationException
- always
-
nextRandom
public double nextRandom()
- Specified by:
nextRandom
in interfaceProbabilityDistribution<Double>
- Returns:
- Not supported
- Throws:
UnsupportedOperationException
- always
-
getDegrees
public double getDegrees()
Gets the number of degrees of freedom.- Returns:
- The number of degrees of freedom
-
getNonCentrality
public double getNonCentrality()
Gets the non-centrality parameter.- Returns:
- The non-centrality parameter
-
-