Compatibility

GAMMAINV

Close: 2 of 5 recorded answers differ in the last bits, worst 2 ULP

Everything else matches (5 workbook cells). Last-bit means a finite number within 16 ULP of Excel's. How we measure this · See the Rust code

Local names in 40 languages
LanguageName in Excel
ArabicGAMMAINV
BulgarianGAMMAINV
CzechGAMMAINV
DanishGAMMAINV
GermanGAMMAINV
GreekGAMMAINV
English (Australia)GAMMAINV
English (United Kingdom)GAMMAINV
English (United States)GAMMAINV
SpanishDISTR.GAMMA.INV
EstonianGAMMAINV
FinnishGAMMAJAKAUMA.KÄÄNT
FrenchLOI.GAMMA.INVERSE
HebrewGAMMAINV
CroatianGAMMAINV
HungarianINVERZ.GAMMA
IndonesianGAMMAINV
ItalianGAMMAINV
JapaneseGAMMAINV
KoreanGAMMAINV
LithuanianGAMMAINV
LatvianGAMMAINV
NorwegianGAMMAINV
DutchGAMMA.INV
PolishROZKŁAD.GAMMA.ODW
Portuguese (Brazil)GAMMAINV
Portuguese (Portugal)INVGAMA
RomanianGAMMAINV
RussianГАММАОБР
SlovakGAMMAINV
SlovenianGAMAINV
Serbian (Latin)GAMMAINV
SwedishGAMMAINV
ThaiGAMMAINV
TurkishGAMATERS işlevi
UkrainianGAMMAINV
VietnameseGAMMAINV
Chinese (Simplified)GAMMAINV
Chinese (Hong Kong)GAMMAINV
Chinese (Traditional)GAMMAINV

Names from Microsoft's support site.

What it does

GAMMAINV(probability, alpha, beta)

GAMMAINV(probability, alpha, beta) inverts the gamma cumulative distribution. Alpha is a positive shape and beta a positive scale. This is the compatibility name.

Try it

Input cells (optional)

Example: {"B2": 3, "B3": 4}. A1 holds the formula. Other cells need values before a formula can read them.

Enter a formula, then calculate.

Runs locally in your browser with OneCalc. Its answer may differ from Excel. Use English function names and commas between arguments.

=GAMMAINV(0.5,1,2) is about 1.38629436111989: the median of the shape-one distribution with scale two is -2*ln(0.5).

Quirks

Alpha and beta must be positive; nonpositive shape or scale gives #NUM!, while text arguments are documented as #VALUE!. The opened legacy page rejects probabilities outside [0,1]. The current shared helper returns zero at p=0 and rejects p=1 with #NUM!, since no finite upper support endpoint is available.

Microsoft describes this legacy inverse as an iterative search over GAMMADIST with a 100-iteration limit and #N/A on failure. Its current GAMMA.INV page describes 64 iterations and also #N/A. This is a difference in published descriptions of the two spellings; it does not establish a measured change between Excel builds or identify either internal search.

How to implement

The current helper searches the positive binary64 lattice rather than stopping at a decimal tolerance:

  1. Validate shape, scale and probability. Return zero at p=0; reject p>=1 or p<0.
  2. Start the upper bound at hi=beta*max(alpha+10*sqrt(alpha)+10,1). The code allows up to 200 doublings while the generic forward value P(alpha,hi/beta) is below p.
  3. With lower bound zero, encode the nonnegative bounds as unsigned binary64 bit integers. Their ordering agrees with numeric ordering.
  4. While the two encodings differ by more than one, bisect their integer encodings and decode the middle value x. If P(alpha,x/beta)>=p, move the upper encoding to it; otherwise move the lower encoding.
  5. Return the upper value once the encodings are adjacent. This chooses the first representable candidate meeting the current forward test under the maintained bracket.

For shape one, scale two and probability one half, the mathematical equation is 1-exp(-x/2)=0.5; its solution is -2*ln(0.5), about 1.38629436111989. That explains the scale and the example, not every last bit of the generic forward search.

The inverse callback calls regularized_gamma_p directly. It does not use every special-case wrapper of public GAMMADIST. Its forward approximation, bracket failures and return policy remain separate compatibility obligations; the current problem report still lists distribution mismatches. This is the current implementable candidate, not a recovered Excel search program.

Rust code

Show the CalcFunc source of this function

Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.

GAMMAINV · 4 lines · calc-func/src/catalogue/distributions.rs on GitHub
57 gammainv "GAMMAINV" (3, 3) [V "probability", V "alpha", V "beta"] |s, a, sv| {
    let [p, alpha, beta] = nums::<3>(s, a)?;
    out(s, bg::gamma_inv_kernel(p, alpha, beta))
}

Kernels shared with other functions

Argument and result plumbing

  • num catalogue/kit
  • out catalogue/kit

No implementation has been published with a Handbook test suite for this function.

Version differences

The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.

Excel 16.0 buildPlatform and CPUCaptured inputs
19929Windows, bitness not recorded, CPU not recorded82

The record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.

Recorded environments and comparison details.

Excel 16.0 build 19929

Windows, bitness not recorded, CPU not recorded

82 captured inputs are indexed for this environment. Capture dates are not recorded. This is a reading count, not a comparison with another build.

Alternatives

GAMMA.INV is the current spelling; EXPON.DIST handles the shape-one waiting time; CHISQ.DIST is a shape/scale specialization.

Named variants

No named variants are recorded yet.

Suggest a correction or contribute an implementation · For agents