Home»Documentation»Statistics Library User's Guide»Continuous Distributions»The Chi Square Distribution

## The Chi Square Distribution | Extreme Optimization Numerical Libraries for .NET Professional |

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:

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);

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

Copyright © 2004-2023,
Extreme Optimization. All rights reserved.

*Extreme Optimization,* *Complexity made simple*, *M#*, and *M
Sharp* are trademarks of ExoAnalytics Inc.

*Microsoft*, *Visual C#, Visual Basic, Visual Studio*, *Visual
Studio.NET*, and the *Optimized for Visual Studio* logo

are
registered trademarks of Microsoft Corporation.