## 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
Modifier and Type Method Description
boolean equals​(Object obj)
double getCDF​(Double x)
Returns the cumulative distribution function for a value
double getDegrees()
Gets the number of degrees of freedom.
double getInverseCDF​(Double p)
Given a probability, return the value that returns this cdf
double getNonCentrality()
Gets the non-centrality parameter.
double getPDF​(Double x)
Return the probability density function for a value
int hashCode()
double nextRandom()
• ### Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### NonCentralChiSquaredDistribution

public NonCentralChiSquaredDistribution​(double degrees,
double nonCentrality)
Creates an instance.
Parameters:
degrees - The number of degrees of freedom, not negative or zero
nonCentrality - The non-centrality parameter, not negative
• ### Method Detail

• #### getCDF

public double getCDF​(Double x)
Returns the cumulative distribution function for a value
Specified by:
getCDF in interface ProbabilityDistribution<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 interface ProbabilityDistribution<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 interface ProbabilityDistribution<Double>
Parameters:
x - The value, not null
Returns:
Not supported
Throws:
UnsupportedOperationException - always
• #### nextRandom

public double nextRandom()
Specified by:
nextRandom in interface ProbabilityDistribution<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
• #### hashCode

public int hashCode()
Overrides:
hashCode in class Object
• #### equals

public boolean equals​(Object obj)
Overrides:
equals in class Object