The chi square (χ2) distribution
with n degrees of freedom models the distribution of
the sum of the squares of n independent normal variables.
It is best known for its use in the Testing Goodness-Of-Fit,
and for the one sample Testing Variances of a sample. The chi square distribution
is a special case of the The Gamma Distribution.
The chi square distribution has one parameter: the degrees of freedom. This value is usually an integer, but this
is not an absolute requirement. The probability density function (PDF) is:
where n is the degrees of freedom.
The chi square distribution is a special case of the gamma distribution, with scale parameter 2 and shape
parameter n/2.
The chi square distribution is implemented by the ChiSquareDistribution class. It has one constructor
which takes the degrees of freedom as its only argument. The following constructs a chi square distribution with 10
degrees of freedom:
var chiSquare = new ChiSquareDistribution(10);
Dim chiSquare = New ChiSquareDistribution(10)
No code example is currently available or this language may not be supported.
let chiSquare = ChiSquareDistribution(10.0)
The ChiSquareDistribution class has one specific property, DegreesOfFreedom, that returns the
degrees of freedom of the distribution.
ChiSquareDistribution has one static (Shared in Visual Basic) method, Sample, which
generates a random sample using a user-supplied uniform random number generator.
var random = new MersenneTwister();
double sample = ChiSquareDistribution.Sample(random, 10);
Dim random = New MersenneTwister()
Dim sample = ChiSquareDistribution.Sample(random, 10)
No code example is currently available or this language may not be supported.
let random = MersenneTwister()
let sample = ChiSquareDistribution.Sample(random, 10.0)
The above example uses the MersenneTwister to
generate uniform random numbers.
For details of the properties and methods common to all continuous distribution classes, see the topic on
continuous distributions..
Other Resources