Skip to content
fn

gammainc

→Tensor
gammainc(input: Tensor, other: Tensor)

Regularized lower incomplete gamma function P(a,x)P(a, x).

P(a,x)=1Γ(a)∫0xta−1e−t dtP(a, x) = \frac{1}{\Gamma(a)} \int_0^x t^{a-1} e^{-t}\, dt

The CDF of a Gamma(a, 1) variable at x — what lucid.distributions.Gamma.cdf evaluates.

Parameters

inputTensor
Shape a≥0a \geq 0.
otherTensor
Upper limit x≥0x \geq 0; broadcast against input.

Returns

Tensor

P(a,x)∈[0,1]P(a, x) \in [0, 1], in the promoted dtype of the two.

Raises

NotImplementedError
From backward, when input requires a gradient: only other is differentiable, with ∂P/∂x=xa−1e−x/Γ(a)\partial P / \partial x = x^{a-1} e^{-x} / \Gamma(a).

Notes

Evaluated by the algorithm of Cephes' igam as SciPy refines it: the power series below x≈ax \approx a, 1 - Q by the continued fraction above, and Temme's uniform asymptotic expansion where a is large and x near it (20<a<20020 < a < 200 with ∣x−a∣/a<0.3|x - a|/a < 0.3, or a>200a > 200 with ∣x−a∣/a<4.5/a|x - a|/a < 4.5/\sqrt{a}). The edges follow the reference framework: P(a,0)=0P(a, 0) = 0, P(a,∞)=1P(a, \infty) = 1, P(0,x)=1P(0, x) = 1 for x>0x > 0, P(∞,x)=0P(\infty, x) = 0 for a finite x; a negative argument, P(0,0)P(0, 0), P(∞,∞)P(\infty, \infty) and NaN answer NaN.

Examples

>>> import lucid
>>> from lucid.special import gammainc
>>> gammainc(lucid.tensor([1.0, 2.0, 3.0]), lucid.tensor([1.0, 2.0, 3.0]))
tensor([0.6321, 0.594, 0.5768])

Used by 1