regularizedIncompleteGammaUpper
regularizedIncompleteGammaUpper(
a,x,options?):number
Defined in: packages/math-analysis/src/regularized-incomplete-gamma-upper.ts:45
The upper regularized incomplete gamma Q(a, x) = 1 − P(a, x) — the fraction
of a Gamma(a, 1) distribution lying above x.
This is the survival function, and in practice it is the p-value: “how often would chance alone produce a result at least this extreme?”. Reach for it whenever the answer is expected to be small, which for a p-value is always.
Not a convenience wrapper over regularizedIncompleteGamma. The tail is
computed directly, where 1 - P subtracts two numbers agreeing to every
digit that mattered: a chi-squared p-value of 1e-12 comes out exact here
and as 0 there.
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
Lower 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
Q(a, x), in [0, 1].
Example
Section titled “Example” regularizedIncompleteGammaUpper(3, 20); // 4.555149505589215e-7 1 - regularizedIncompleteGamma(3, 20); // 4.5551495053697266e-7 — diverges at the 10th digit ```;
## Throws
When `a ≤ 0` or `x < 0`.
## Throws
When neither expansion met the tolerance.
## See
- [regularizedIncompleteGamma](regularizedIncompleteGamma.md) when the answer is near 0. - [Incomplete gamma and beta](https://anthochamp.pages.grenadine.io/node-essentials/topics/math/functions/incomplete-gamma-beta/)