The chi-squared distribution #
The chi-squared law with k degrees of freedom is the gamma law of shape k / 2 and rate 1 / 2.
This file defines it for every real k, records its three parameter regimes, and transports the
elementary theory of the gamma law across the bridge: the density, the cumulative distribution
function, the mean k, the variance 2 * k, the exponential-moment domain Set.Iio (1 / 2), the
moment- and cumulant-generating functions there, and the characteristic function. It also proves
that the family is additive in its degrees of freedom.
The three regimes. Only 0 < k gives a gamma law. At k = 0 the shape would degenerate, and
the law is defined to be Measure.dirac 0: that is the value forced by additivity, since a
convolution unit must be a point mass at the origin, and it is the law of an empty sum of squared
standard Gaussians. Below 0 there is no law at all, and the measure is 0. The boundary at
k = 0 is singular with respect to Lebesgue measure, so it carries its own moment and transform
formulas rather than a density.
Main definitions #
TauCeti.Probability.chiSquaredPDFReal— the real-valued candidate density formula,x ^ (k / 2 - 1) * exp (-x / 2) / (2 ^ (k / 2) * Γ (k / 2))on[0, ∞), which is a probability density when0 < k;TauCeti.Probability.chiSquaredPDF— itsℝ≥0∞-valued companion, which is a probability density when0 < k;TauCeti.Probability.chiSquaredMeasure— the law.
Main results #
TauCeti.Probability.chiSquaredMeasure_eq_gammaMeasure— the bridge to the gamma law;TauCeti.Probability.isProbabilityMeasure_chiSquaredMeasure— it is a probability measure for every0 ≤ k, the boundaryk = 0included;TauCeti.Probability.chiSquaredMeasure_eq_withDensity,TauCeti.Probability.hasPDF_of_hasLaw_chiSquaredMeasureandTauCeti.Probability.rnDeriv_chiSquaredMeasure— the density, as awithDensitypresentation, aMeasureTheory.HasPDFbridge and a Radon–Nikodym derivative;TauCeti.Probability.measurable_chiSquaredMeasure— measurability in the degrees of freedom, so the family can be used as a kernel;TauCeti.Probability.cdf_chiSquaredMeasure_eq— the cdf isP (k / 2, x / 2);TauCeti.Probability.integral_id_chiSquaredMeasureandTauCeti.Probability.variance_id_chiSquaredMeasure— the meankand the variance2 * k;TauCeti.Probability.integrableExpSet_id_chiSquaredMeasure,TauCeti.Probability.mgf_id_chiSquaredMeasureandTauCeti.Probability.cgf_id_chiSquaredMeasure— for0 < kthe exponential moments exist exactly below1 / 2; on that half-line the mgf is(1 - 2 * t) ^ (-(k / 2))for every0 ≤ k;TauCeti.Probability.charFun_chiSquaredMeasure— the characteristic function is(1 - 2 * I * t) ^ (-k / 2), for every realt;TauCeti.Probability.integral_id_chiSquaredMeasure_zero,TauCeti.Probability.variance_id_chiSquaredMeasure_zeroandTauCeti.Probability.charFun_chiSquaredMeasure_zero— at the Dirac boundaryk = 0the mean and variance vanish and the characteristic function is identically1;TauCeti.Probability.chiSquaredMeasure_conv_chiSquaredMeasure— degrees of freedom add under convolution;TauCeti.Probability.chiSquaredMeasure_two— two degrees of freedom give the exponential law of rate1 / 2.
Implementation #
Every positive-parameter statement is the gamma statement of shape k / 2 and rate 1 / 2, read
through chiSquaredMeasure_eq_gammaMeasure; nothing is recomputed. The arithmetic that remains is
the substitution r = 1 / 2 in the gamma formulas: it turns a / r into k, a / r ^ 2 into
2 * k, and (1 - t / r) ^ (-a) into (1 - 2 * t) ^ (-(k / 2)).
The density is stated in the textbook normalisation 2 ^ (k / 2) * Γ (k / 2) rather than as
gammaPDFReal (k / 2) (1 / 2), and chiSquaredPDFReal_eq_gammaPDFReal identifies the two; the
only content of that identification is (1 / 2) ^ (k / 2) = (2 ^ (k / 2))⁻¹.
The boundary k = 0 uses the Dirac formulas of TauCeti/Probability/Distributions/Dirac.lean
together with Mathlib's ProbabilityTheory.mgf_dirac', ProbabilityTheory.variance_dirac and
MeasureTheory.charFun_dirac. Its exponential-moment domain is all of ℝ, strictly larger than
the positive-parameter domain Set.Iio (1 / 2), which is why the two regimes cannot share a
statement.
References #
- Roadmap:
TauCetiRoadmap/StandardDistributions/README.md, Layer 3, the Chi-squared target, together with the chi-squared case of items 1–4 of "What every distribution must provide", and the completion checkchiSquaredMeasure 2 = expMeasure (1 / 2). - Formal declaration scaffold:
TauCetiRoadmap/StandardDistributions/Suggested.lean, Layer 3. - N. L. Johnson, S. Kotz, N. Balakrishnan, Continuous Univariate Distributions, vol. 1, 2nd ed., Wiley (1994), ch. 18.
The density #
The candidate density formula for the chi-squared law with k degrees of freedom, in the
textbook normalisation: x ^ (k / 2 - 1) * exp (-x / 2) / (2 ^ (k / 2) * Γ (k / 2)) on the
nonnegative half-line, and 0 below it. It is a probability density when 0 < k.
Instances For
The ℝ≥0∞-valued companion to chiSquaredPDFReal. It is a probability density when
0 < k.
Instances For
The extended candidate density is obtained from its real companion.
Below zero, the candidate real-valued chi-squared density vanishes.
On the nonnegative half-line, the ℝ≥0∞-valued candidate chi-squared density is given by its
textbook formula.
Below zero, the ℝ≥0∞-valued candidate chi-squared density vanishes.
At zero degrees of freedom the real candidate density vanishes identically.
At zero degrees of freedom the extended candidate density vanishes identically.
The chi-squared density is the gamma density of shape k / 2 and rate 1 / 2.
The ℝ≥0∞-valued chi-squared density is the gamma density of shape k / 2 and rate
1 / 2.
The chi-squared density is nonnegative for nonnegative degrees of freedom.
The real-valued chi-squared density is measurable.
The chi-squared density is measurable.
The measure and its three regimes #
The chi-squared law with k degrees of freedom: the gamma law of shape k / 2 and rate
1 / 2 for 0 < k, the point mass at the origin for k = 0, and the zero measure for k < 0.
Instances For
For positive degrees of freedom the chi-squared law is a gamma law.
At zero degrees of freedom the chi-squared law is the point mass at the origin.
There is no chi-squared law with negative degrees of freedom: the measure is zero.
The chi-squared law is a probability measure for every nonnegative number of degrees of
freedom, the boundary k = 0 included.
A chi-squared law of positive degree has no atoms.
A chi-squared law of positive degree gives zero mass to every singleton.
A chi-squared variable of positive degree is positive almost surely.
Every chi-squared measure is carried by the nonnegative half-line, including its Dirac and invalid zero-measure cases.
For positive degrees of freedom the chi-squared law has the chi-squared density with respect to Lebesgue measure.
The chi-squared family is measurable in its degrees of freedom, so it can be used as a kernel.
Densities of random variables #
A variable with a chi-squared law of positive degrees of freedom has a density.
The density of a chi-squared law of positive degrees of freedom is chiSquaredPDF.
The Radon–Nikodym derivative of a chi-squared law of positive degrees of freedom is
chiSquaredPDF.
The cumulative distribution function #
The cumulative distribution function of a chi-squared law with positive degrees of freedom is
the regularized lower incomplete gamma function P (k / 2, x / 2).
At zero degrees of freedom the cumulative distribution function is the unit step at the origin.
Moments #
At zero degrees of freedom the mean is 0.
At zero degrees of freedom the variance is 0.
The mean of a chi-squared law with nonnegative degrees of freedom is its number of degrees of freedom.
The variance of a chi-squared law with nonnegative degrees of freedom is twice its number of degrees of freedom.
A real power is integrable under a positive-degree chi-squared law exactly when its exponent is greater than minus half the number of degrees of freedom.
A product of real powers of independent positive-degree chi-squared coordinates is integrable exactly when the exponent is greater than minus half of every coordinate's degrees of freedom.
Exponential moments and transforms #
The exponential moments of a chi-squared law with positive degrees of freedom are exactly
those of rate t < 1 / 2.
The cumulant-generating function of a chi-squared law with nonnegative degrees of freedom on
the half-line t < 2⁻¹. It is the real logarithm of
TauCeti.Probability.mgf_id_chiSquaredMeasure.
At zero degrees of freedom the characteristic function is identically 1.
The characteristic function of a chi-squared law with nonnegative degrees of freedom, at every
real t. The base has real part 1, so the principal power does not meet the branch cut.
At zero degrees of freedom every exponential moment exists.
At zero degrees of freedom the moment-generating function is identically 1.
At zero degrees of freedom the cumulant-generating function is identically 0.
Additivity and the exponential law #
Degrees of freedom add under convolution, including at the boundary k = 0, where the
chi-squared law is the convolution unit.
A finite sum of independent chi-squared variables has the chi-squared law whose degrees of freedom are the sum of the individual degrees of freedom.
Two degrees of freedom give the exponential law of rate 1 / 2.