The lower incomplete gamma function #
For a positive shape parameter s this file introduces
TauCeti.lowerIncompleteGamma s x = ∫ t in 0..x, t ^ (s - 1) * exp (-t), the truncation of Euler's integral atx, extended by0forx ≤ 0and fors ≤ 0; andTauCeti.regularizedGamma s x = lowerIncompleteGamma s x / Real.Gamma s, its normalization, again extended by0fors ≤ 0.
Classically these are γ(s, x) and P(s, x). The regularized function is the cumulative
distribution function of a Gamma law, which is where this file is headed; the two totalizations
above make that cdf agree with the clamping conventions a cdf needs, below the support and outside
the parameter range.
Main definitions #
TauCeti.lowerIncompleteGamma— the lower incomplete gamma functionγ(s, x);TauCeti.regularizedGamma— the regularized lower incomplete gamma functionP(s, x).
Main results #
TauCeti.lowerIncompleteGamma_eq_integralandTauCeti.regularizedGamma_eq_div— the characteristic descriptions replacing the clamped definitions;TauCeti.intervalIntegrable_rpow_mul_exp_neg— convergence of Euler's integrand on an interval, including at the singularity0fors < 1;TauCeti.continuous_lowerIncompleteGamma,TauCeti.continuous_regularizedGamma— continuity on all ofℝ, in particular atx = 0, where fors < 1the integrand blows up;TauCeti.lowerIncompleteGamma_monotone,TauCeti.regularizedGamma_monotone— monotonicity, andTauCeti.lowerIncompleteGamma_nonneg,TauCeti.regularizedGamma_nonneg,TauCeti.regularizedGamma_le_one— the range;TauCeti.hasDerivAt_lowerIncompleteGamma,TauCeti.hasDerivAt_regularizedGammaand the companionderivlemmas — differentiability, for0 < xonly;TauCeti.lowerIncompleteGamma_add_oneandTauCeti.regularizedGamma_add_one— the recurrenceγ(s + 1, x) = s * γ(s, x) - x ^ s * exp (-x)and its regularized formP(s + 1, x) = P(s, x) - x ^ s * exp (-x) / Γ(s + 1), both for0 < sand0 ≤ x;TauCeti.tendsto_lowerIncompleteGamma_atTop,TauCeti.tendsto_regularizedGamma_atTop— the limitsReal.Gamma sand1asx → ∞, with the resulting boundsTauCeti.lowerIncompleteGamma_le_GammaandTauCeti.regularizedGamma_le_one;TauCeti.regularizedGamma_one—P(1, x) = 1 - e ^ (-x)for0 ≤ x, the exponential cdf.TauCeti.Real.erf_eq_regularizedGamma_half_sq— the error function is the regularized incomplete gamma function of shape1 / 2after squaring, on the nonnegative half-line.
Implementation #
The guard 0 < s in the definition of regularizedGamma mirrors the one built into
TauCeti.lowerIncompleteGamma, which is the definition shape the roadmap prescribes. It changes no
value: γ(s, x) already vanishes for s ≤ 0, so dividing unconditionally would give the same
function, and TauCeti.regularizedGamma_eq_div accordingly needs no hypothesis on s.
The limit at infinity is Mathlib's Real.GammaIntegral_convergent together with
Real.Gamma_eq_integral, which state Euler's integrand as exp (-t) * t ^ (s - 1); this file uses
the opposite factor order throughout, so both are applied up to mul_comm at their point of use.
The recurrence is obtained from Mathlib's Complex.partialGamma_add_one, whose proof performs the
integration by parts on Set.Ioo 0 x — the endpoint 0 has to be avoided because t ^ s is not
differentiable there for s < 1. The bridge is
TauCeti.ofReal_lowerIncompleteGamma_eq_partialGamma, which identifies γ(s, x) with
Complex.partialGamma s x for real s.
References #
Convergence of the truncated Euler integral #
Euler's integrand t ^ p * exp (-t) is interval integrable, for -1 < p.
This composes Mathlib's intervalIntegral.intervalIntegrable_rpow', which carries the singularity
at 0 for p < 0, with the continuous factor. The shape parameter s of
TauCeti.lowerIncompleteGamma enters as p = s - 1.
The definitions #
The lower incomplete gamma function γ(s, x) = ∫ t in 0..x, t ^ (s - 1) * exp (-t).
It is 0 for x ≤ 0, where the truncated integral is empty, and 0 for s ≤ 0, where Euler's
integral diverges at the origin.
Equations
Instances For
The regularized lower incomplete gamma function P(s, x) = γ(s, x) / Γ(s), extended by 0
outside the valid range 0 < s of the shape parameter.
Equations
- TauCeti.regularizedGamma s x = if 0 < s then TauCeti.lowerIncompleteGamma s x / Real.Gamma s else 0
Instances For
Outside the valid range of the shape parameter, γ(s, x) is 0.
Below the support, γ(s, x) is 0.
Outside the valid range of the shape parameter, P(s, x) is 0.
P(s, x) is γ(s, x) normalized by Γ(s).
No hypothesis on the shape parameter is needed: for s ≤ 0 both sides are 0, since γ(s, ·)
is.
Below the support, P(s, x) is 0.
Positivity, monotonicity and regularity #
γ(s, x) is nonnegative, for every parameter value.
P(s, x) is nonnegative, for every parameter value.
γ(s, ·) is monotone: it accumulates a nonnegative integrand.
P(s, ·) is monotone. For 0 < s, this together with TauCeti.regularizedGamma_nonneg,
TauCeti.regularizedGamma_le_one, TauCeti.regularizedGamma_eq_zero_of_nonpos_right,
TauCeti.continuous_regularizedGamma and TauCeti.tendsto_regularizedGamma_atTop is everything a
cumulative distribution function must satisfy.
γ(s, ·) is continuous on all of ℝ.
For s < 1 this includes the point x = 0, where the integrand is unbounded; the integral is
nevertheless convergent there, by TauCeti.intervalIntegrable_rpow_mul_exp_neg.
P(s, ·) is continuous on all of ℝ.
γ(s, ·) is differentiable at every positive x, with the expected derivative.
The hypothesis 0 < x cannot be weakened to 0 ≤ x: among the positive shapes this theorem is
stated for, differentiability at 0 holds exactly for 1 < s. For s < 1 the integrand is
unbounded at 0, and at s = 1 the clamped function is x ↦ 1 - exp (-max x 0), whose one-sided
derivatives at 0 are 0 and 1. (For s ≤ 0 the function is identically 0, hence trivially
differentiable everywhere.)
P(s, ·) is differentiable at every positive x, with the expected derivative. As for
TauCeti.hasDerivAt_lowerIncompleteGamma, the hypothesis 0 < x is needed at every shape
0 < s ≤ 1.
The derivative of P(s, ·) at a positive point is the normalized integrand.
The recurrence in the shape parameter #
For a positive real shape parameter s and 0 ≤ x, γ(s, x) is Mathlib's
Complex.partialGamma at (s : ℂ).
The complex partial gamma function carries the integration by parts behind
TauCeti.lowerIncompleteGamma_add_one, so this identification is what lets that recurrence be
imported rather than reproved.
The recurrence γ(s + 1, x) = s * γ(s, x) - x ^ s * exp (-x), for 0 < s and 0 ≤ x.
The regularized form of the recurrence, P(s + 1, x) = P(s, x) - x ^ s * exp (-x) / Γ(s + 1),
for 0 < s and 0 ≤ x. The factor s of TauCeti.lowerIncompleteGamma_add_one is absorbed by
Real.Gamma_add_one.
The limit at infinity #
γ(s, x) increases to the complete Euler integral Real.Gamma s as x → ∞.
A truncated Euler integral is at most the complete one.
P(s, x) increases to 1 as x → ∞: it is the cumulative distribution function of a
probability law.
P(s, x) is at most 1, for every parameter value.
The exponential case s = 1 #
γ(1, x) = 1 - exp (-x) for 0 ≤ x.
P(1, x) = 1 - exp (-x) for 0 ≤ x: the regularized lower incomplete gamma function at shape
1 is the cumulative distribution function of the standard exponential law.
Relation with the error function #
On the positive half-line, the regularized incomplete gamma function of shape 1 / 2,
composed with squaring, has the Gaussian derivative which defines the error function.
For 0 ≤ x, the error function is the regularized lower incomplete gamma function of shape
1 / 2 evaluated at x². The restriction is necessary because the right-hand side is even,
whereas the error function is odd.