## Class ChiSquareDistribution

• java.lang.Object
• com.opengamma.strata.math.impl.statistics.distribution.ChiSquareDistribution
• All Implemented Interfaces:
ProbabilityDistribution<Double>

public class ChiSquareDistribution
extends Object
implements ProbabilityDistribution<Double>
A $\chi^2$ distribution with $k$ degrees of freedom is the distribution of the sum of squares of $k$ independent standard normal random variables with cdf and inverse cdf \begin{align*} F(x) &=\frac{\gamma\left(\frac{k}{2}, \frac{x}{2}\right)}{\Gamma\left(\frac{k}{2}\right)}\\ F^{-1}(p) &= 2\gamma^{-1}\left(\frac{k}{2}, p\right) \end{align*} where $\gamma(y, z)$ is the lower incomplete Gamma function and $\Gamma(y)$ is the Gamma function. The pdf is given by: \begin{align*} f(x)=\frac{x^{\frac{k}{2}-1}e^{-\frac{x}{2}}}{2^{\frac{k}{2}}\Gamma\left(\frac{k}{2}\right)} \end{align*}
• ### Constructor Summary

Constructors
Constructor Description
ChiSquareDistribution​(double degrees)
Creates an instance.
ChiSquareDistribution​(double degrees, RandomEngine engine)
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 getDegreesOfFreedom()
Gets the degrees of freedom.
double getInverseCDF​(Double p)
Given a probability, return the value that returns this cdf
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

• #### ChiSquareDistribution

public ChiSquareDistribution​(double degrees)
Creates an instance.
Parameters:
degrees - The degrees of freedom of the distribution, not less than one
• #### ChiSquareDistribution

public ChiSquareDistribution​(double degrees,
RandomEngine engine)
Creates an instance.
Parameters:
degrees - The degrees of freedom of the distribution, not less than one
engine - A uniform random number generator, not null
• ### 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
• #### 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:
The pdf
• #### 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:
The inverse cdf
• #### nextRandom

public double nextRandom()
Specified by:
nextRandom in interface ProbabilityDistribution<Double>
Returns:
The next random number from this distribution
• #### getDegreesOfFreedom

public double getDegreesOfFreedom()
Gets the degrees of freedom.
Returns:
The number of degrees of freedom
• #### hashCode

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

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