Skip to content

inverseRegularizedIncompleteGamma

inverseRegularizedIncompleteGamma(a, p, options?): number

Defined in: packages/math-analysis/src/inverse-regularized-incomplete-gamma.ts:84

The inverse of regularizedIncompleteGamma in its second argument: the x at which P(a, x) equals p.

This is the quantile function — the “which value sits at the 95th percentile?” direction, where P answers “which percentile is this value at?”. It is what the Gamma, ChiSquared and Poisson quantiles in @ac-kit/math-stats are built on, and what turns a confidence level into a critical value.

Accurate to within a few ulps in the round trip: feeding the result back through P returns the p you started from to about 1e-15 relative.

O(maxIterations) evaluations of P or Q in the worst case; three or four in practice, because convergence is cubic. O(1) memory.

number

Shape parameter, positive.

number

Probability, in [0, 1].

ConvergenceOptions

Termination criteria; tolerance is compared against the relative size of the refinement step and defaults to Number.EPSILON, maxIterations to 100.

number

The x with P(a, x) = p; 0 at p = 0 and Infinity at p = 1.

const median = inverseRegularizedIncompleteGamma(3, 0.5); // 2.674060313723559
regularizedIncompleteGamma(3, median); // 0.4999999999999999 — back where we started
```;
## Throws
When `a ≤ 0` or `p` is outside `[0, 1]`.
## See
- [regularizedIncompleteGamma](regularizedIncompleteGamma.md) for the forward direction.
- [Incomplete gamma and beta](https://anthochamp.pages.grenadine.io/node-essentials/topics/math/functions/incomplete-gamma-beta/)