ChiSquaredDistribution
Represents the chi-squared distribution, a continuous probability distribution defined on the interval [0, +infinity).
The chi-squared distribution describes the distribution of a sum of squared standard normal random variables. It is one of the most widely used distributions in statistical inference, appearing in chi-squared goodness-of-fit tests, tests of independence in contingency tables, and confidence intervals for population variance. The single parameter degreesOfFreedom determines the shape: higher values shift the distribution to the right and make it more symmetric.
Internally, this distribution is implemented as a special case of the Gamma distribution with shape equal to half the degrees of freedom and rate equal to 0.5. The CDF, quantile, and sampling methods all delegate to this underlying Gamma parameterization.
Example:
val dist = ChiSquaredDistribution(degreesOfFreedom = 5.0)
dist.mean // 5.0 (equal to the degrees of freedom)
dist.variance // 10.0 (twice the degrees of freedom)
dist.pdf(3.0) // 0.1542... (density at x = 3)
dist.cdf(11.07) // 0.95 (approximately)
// Quantile for a chi-squared test critical value
dist.quantile(0.95) // 11.07... (95th percentile with 5 df)