Documentation

TauCeti.Probability.Distributions.Gamma.Basic

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 #

The cumulative distribution function is computed in TauCeti/Probability/Distributions/Gamma/Cdf.lean.

References #

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.

Almost every point of a product of two gamma laws with positive parameters lies in the open positive quadrant.

@[simp]
theorem TauCeti.Probability.gammaPDFReal_of_nonneg {a r x : ℝ} (hx : 0 ≤ x) :
ProbabilityTheory.gammaPDFReal a r x = r ^ a / Real.Gamma a * x ^ (a - 1) * Real.exp (-(r * x))

Off the negative half-line the gamma density is given by its closed formula.

Integrability transfer. A function is integrable against a gamma law with positive shape and rate exactly when its density-weighted version is Lebesgue integrable.

theorem TauCeti.Probability.integral_gammaMeasure_eq {a r : ℝ} {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] (ha : 0 < a) (hr : 0 < r) (g : ℝ → E) :

Integral transfer. An integral against a gamma law with positive shape and rate is the density-weighted Lebesgue integral.

theorem TauCeti.Probability.integral_gammaMeasure_eq_integral_Ioi {a r : ℝ} {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] (ha : 0 < a) (hr : 0 < r) (f : ℝ → E) :
∫ (x : ℝ), f x ∂ProbabilityTheory.gammaMeasure a r = ∫ (x : ℝ) in Set.Ioi 0, (r ^ a / Real.Gamma a * x ^ (a - 1) * Real.exp (-(r * x))) • f x

An integral against the gamma law is the set integral of the weighted integrand over (0, ∞).

Raw moments, mean and variance #

@[simp]
theorem TauCeti.Probability.integral_pow_gammaMeasure {a r : ℝ} (ha : 0 < a) (hr : 0 < r) (n : ℕ) :

The nth raw moment of a gamma law with positive shape and rate.

@[simp]
theorem TauCeti.Probability.integrable_inv_pow_gammaMeasure_iff {a r : ℝ} (ha : 0 < a) (hr : 0 < r) (n : ℕ) :

The nth inverse power is integrable under a Gamma law exactly when n is below the shape.

@[simp]
theorem TauCeti.Probability.integral_inv_pow_gammaMeasure {a r : ℝ} (hr : 0 < r) (n : ℕ) (hn : ↑n < a) :

The nth inverse moment of a Gamma law, when n is below the shape.

@[simp]
theorem TauCeti.Probability.integral_id_gammaMeasure {a r : ℝ} (ha : 0 < a) (hr : 0 < r) :

The mean of a gamma law with positive shape and rate is a / r.

@[simp]
theorem TauCeti.Probability.integral_sq_gammaMeasure {a r : ℝ} (ha : 0 < a) (hr : 0 < r) :
∫ (x : ℝ), x ^ 2 ∂ProbabilityTheory.gammaMeasure a r = a * (a + 1) / r ^ 2

The second raw moment of a gamma law with positive shape and rate is a * (a + 1) / r ^ 2.

Exponential moments #

theorem TauCeti.Probability.integrable_exp_mul_id_gammaMeasure {a r : ℝ} (ha : 0 < a) (hr : 0 < r) {t : ℝ} (ht : t < r) :

Below the rate of a gamma law, its exponential moments exist.

theorem TauCeti.Probability.integrable_pow_gammaMeasure {a r : ℝ} (ha : 0 < a) (hr : 0 < r) (n : ℕ) :

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.

theorem TauCeti.Probability.not_integrable_exp_mul_id_gammaMeasure {a r : ℝ} (ha : 0 < a) (hr : 0 < r) {t : ℝ} (ht : r ≤ t) :

At or above the rate of a gamma law, its exponential moments do not exist.

@[simp]

The exponential moments of a gamma law of rate r are exactly those of rate t < r.

@[simp]
theorem TauCeti.Probability.mgf_id_gammaMeasure {a r : ℝ} (ha : 0 < a) (hr : 0 < r) {t : ℝ} (ht : t < r) :

The moment-generating function of a gamma law on the half-line where its exponential moment is integrable, namely t < r.

@[simp]
theorem TauCeti.Probability.cgf_id_gammaMeasure {a r : ℝ} (ha : 0 < a) (hr : 0 < r) {t : ℝ} (ht : 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.

@[simp]

The variance of a gamma law with positive shape and rate is a / r ^ 2.

Convolution #

@[simp]

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 #

@[simp]
theorem TauCeti.Probability.gammaMeasure_map_const_mul {a r : ℝ} (ha : 0 < a) (hr : 0 < r) {c : ℝ} (hc : 0 < c) :

Scaling a gamma variable by c > 0 divides its rate by c.