Elementary theory of the gamma distribution #
This file develops the elementary moment theory of Mathlib's gamma distribution. For a positive
shape a and a positive rate r it computes every natural raw moment, the mean and the variance,
every natural inverse moment that exists, the exact set of rates at which an exponential moment
exists, and the moment- and cumulant-generating functions on that set. It also identifies the law
of a positive rescaling: only the rate moves, and it moves by the scaling factor. Finally, it
proves that the convolution of two gamma laws with the same rate adds their shape parameters.
The moment and transform computations go through the same two reductions. The measure
gammaMeasure a r is
volume.withDensity of a density carried by [0, ∞), so an integral against it is a set integral
of the weighted integrand over (0, ∞), and integrability against it is integrability of that same
weighted integrand over (0, ∞). Raw moments and exponential moments then both reduce to Euler's
integral through Real.integral_rpow_mul_exp_neg_mul_Ioi, whose shape
x ^ (s - 1) * exp (-(b * x)) they match after collecting exponents: a factor x ^ n shifts the
shape from a to a + n, and a factor exp (t * x) shifts the rate from r to r - t. The
second shift explains the exponential moment domain: it is exactly the half-line on which the
shifted rate is still positive. A factor (x ^ n)⁻¹ shifts the shape the other way, from a to
a - n, and Euler's integral converges exactly when that shifted shape is still positive, which is
the inverse-moment threshold n < a.
Main results #
TauCeti.Probability.integrable_gammaMeasure_iffandTauCeti.Probability.integral_gammaMeasure_eq— integrability and integration against the gamma law, transferred to the real density;TauCeti.Probability.integral_pow_gammaMeasure— the natural raw moments,Γ (a + n) / (Γ a * r ^ n), withTauCeti.Probability.integral_id_gammaMeasureandTauCeti.Probability.integral_sq_gammaMeasureas the first two cases;TauCeti.Probability.integrable_inv_pow_gammaMeasure_iff— thenth inverse power is integrable exactly below the shape,n < a, andTauCeti.Probability.integral_inv_pow_gammaMeasure— that inverse moment isr ^ n * Γ (a - n) / Γ a;TauCeti.Probability.variance_id_gammaMeasure— the variance isa / r ^ 2;TauCeti.Probability.integrable_exp_mul_id_gammaMeasureandTauCeti.Probability.not_integrable_exp_mul_id_gammaMeasure— the exponential moment of ratetexists exactly whent < r, recorded as an equality of sets inTauCeti.Probability.integrableExpSet_id_gammaMeasure;TauCeti.Probability.mgf_id_gammaMeasure— the moment-generating function is(1 - t / r) ^ (-a)there;TauCeti.Probability.cgf_id_gammaMeasure— the cumulant-generating function is-a * log (1 - t / r)there, the real logarithm of the previous formula;TauCeti.Probability.gammaMeasure_conv_gammaMeasure— convolution at a common rate adds the shape parameters;TauCeti.Probability.gammaMeasure_map_const_mul— scaling byc > 0sends the ratertor / c;TauCeti.Probability.gammaMeasure_eq_withDensity_restrict_Ioi— the law is its density against Lebesgue measure onIoi 0;
The cumulative distribution function is computed in
TauCeti/Probability/Distributions/Gamma/Cdf.lean.
References #
- Tau Ceti roadmap,
StandardDistributions, Layer 1, "Gamma". - N. L. Johnson, S. Kotz, N. Balakrishnan, Continuous Univariate Distributions, vol. 1, 2nd ed., Wiley, 1994, ch. 17.
A Gamma measure is sigma-finite for all parameter values.
Reduction to the positive half-line #
A gamma measure is almost everywhere strictly positive, for all parameter values.
The gamma law is its density against Lebesgue measure on the open positive half-line: the density vanishes below the origin, and the origin itself is null.
The gamma law presented by its real-valued density.
Integrability transfer. A function is integrable against a gamma law with positive shape and rate exactly when its density-weighted version is Lebesgue integrable.
Integral transfer. An integral against a gamma law with positive shape and rate is the density-weighted Lebesgue integral.
An integral against the gamma law is the set integral of the weighted integrand over
(0, ∞).
Raw moments, mean and variance #
The nth raw moment of a gamma law with positive shape and rate.
The nth inverse power is integrable under a Gamma law exactly when n is below the
shape.
The nth inverse moment of a Gamma law, when n is below the shape.
Exponential moments #
Below the rate of a gamma law, its exponential moments exist.
Every natural power is integrable under a gamma law with positive shape and rate.
The identity function belongs to L² of a gamma law with positive shape and rate.
At or above the rate of a gamma law, its exponential moments do not exist.
The exponential moments of a gamma law of rate r are exactly those of rate t < r.
The cumulant-generating function of a gamma law on the half-line where its exponential moment
is integrable, namely t < r. It is the real logarithm of
TauCeti.Probability.mgf_id_gammaMeasure.
The variance of a gamma law with positive shape and rate is a / r ^ 2.
Convolution #
The convolution of two gamma laws with a common positive rate is a gamma law whose shape is the sum of the two positive shapes.
Scaling #
Scaling a gamma variable by c > 0 divides its rate by c.