GAMMAINCCINV
This function solves for the nonnegative argument x in the regularized upper incomplete gamma equation for a fixed positive shape parameter.
It finds x such that:
y=Q(a,x)
where Q(a,x) is the regularized upper incomplete gamma function. For valid inputs, the output decreases as y increases.
Excel Usage
=GAMMAINCCINV(a, y)
a(float, required): Positive shape parameter.y(float, required): Upper-tail target value in the unit interval.
Returns (float): Nonnegative x value satisfying the inverse upper incomplete gamma equation.
Example 1: Inverse upper incomplete gamma at zero probability
Inputs:
| a | y |
|---|---|
| 0.5 | 0 |
Excel formula:
=GAMMAINCCINV(0.5, 0)
Expected output:
"Infinity"
Example 2: Inverse upper incomplete gamma at tenth probability
Inputs:
| a | y |
|---|---|
| 0.5 | 0.1 |
Excel formula:
=GAMMAINCCINV(0.5, 0.1)
Expected output:
1.35277
Example 3: Inverse upper incomplete gamma at median probability
Inputs:
| a | y |
|---|---|
| 2 | 0.5 |
Excel formula:
=GAMMAINCCINV(2, 0.5)
Expected output:
1.67835
Example 4: Inverse upper incomplete gamma at one probability
Inputs:
| a | y |
|---|---|
| 1.5 | 1 |
Excel formula:
=GAMMAINCCINV(1.5, 1)
Expected output:
0
Python Code
from scipy.special import gammainccinv as scipy_gammainccinv
def gammainccinv(a, y):
"""
Invert the regularized upper incomplete gamma function.
See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.gammainccinv.html
This example function is provided as-is without any representation of accuracy.
Args:
a (float): Positive shape parameter.
y (float): Upper-tail target value in the unit interval.
Returns:
float: Nonnegative x value satisfying the inverse upper incomplete gamma equation.
"""
try:
if a <= 0:
return "Error: a must be positive"
if y < 0 or y > 1:
return "Error: y must be between 0 and 1"
return float(scipy_gammainccinv(a, y))
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Positive shape parameter.
Upper-tail target value in the unit interval.