regularizedIncompleteGamma
regularizedIncompleteGamma(
a,x,options?):number
Defined in: packages/math-analysis/src/regularized-incomplete-gamma.ts:51
The lower regularized incomplete gamma P(a, x) — the fraction of a
Gamma(a, 1) distribution lying at or below x.
In plain terms it answers “what proportion of outcomes are no bigger than this?”, which makes it the cumulative distribution function of the gamma, chi-squared and Poisson families. Feed it a chi-squared statistic and you get the probability of seeing something that small.
Regularized is spelled out because libraries disagree about whether the
bare name means this ratio in [0, 1] or the unnormalised integral. Guessing
wrong is silent and off by a factor of Γ(a).
Reach for regularizedIncompleteGammaUpper when the answer is near 1:
1 - P there has already thrown away the digits the upper form keeps, which
is the difference between a p-value of 1e-12 and a p-value of 0.
Relative error is within a few ulps for ordinary parameters and stays under
about 5e-13 for large ones.
O(maxIterations) calls to the underlying expansion in the worst case, and
far fewer in practice; O(1) memory.
Parameters
Section titled “Parameters”number
Shape parameter, positive.
number
Upper limit, non-negative.
options?
Section titled “options?”Termination criteria; tolerance is relative and defaults to
Number.EPSILON, maxIterations to 1000.
Returns
Section titled “Returns”number
P(a, x), in [0, 1].
Example
Section titled “Example” regularizedIncompleteGamma(0.5, 1); // 0.8427007929497148 — this is erf(1) regularizedIncompleteGamma(3, 20); // 0.9999995444850495 1 - regularizedIncompleteGamma(3, 20); // 4.5551495053697266e-7 — only 9 good digits ```;
## Throws
When `a ≤ 0` or `x < 0`.
## Throws
When neither expansion met the tolerance.
## See
- [regularizedIncompleteGammaUpper](regularizedIncompleteGammaUpper.md) when the answer is small. - [inverseRegularizedIncompleteGamma](inverseRegularizedIncompleteGamma.md) to go the other way. - [Incomplete gamma and beta](https://anthochamp.pages.grenadine.io/node-essentials/topics/math/functions/incomplete-gamma-beta/)