INVGAMMA_POST_Q
This function returns a quantile from an inverse-Gamma distribution, which commonly appears as a conjugate posterior for variance parameters in normal models.
For shape \alpha, scale \beta, and probability level p, it computes q_p such that:
P(X \le q_p) = p, \quad X \sim \text{InvGamma}(\alpha, \beta)
The result is often used as a posterior credible bound for unknown variance.
Excel Usage
=INVGAMMA_POST_Q(shape, scale, prob)
shape(float, required): Inverse-Gamma shape parameter (positive).scale(float, required): Inverse-Gamma scale parameter (positive).prob(float, required): Target cumulative probability level in [0, 1].
Returns (float): Inverse-Gamma posterior quantile for the requested probability level.
Example 1: Median inverse-Gamma posterior quantile
Inputs:
| shape | scale | prob |
|---|---|---|
| 8 | 12 | 0.5 |
Excel formula:
=INVGAMMA_POST_Q(8, 12, 0.5)
Expected output:
1.56469
Example 2: Lower-tail variance credible bound
Inputs:
| shape | scale | prob |
|---|---|---|
| 5.5 | 7 | 0.1 |
Excel formula:
=INVGAMMA_POST_Q(5.5, 7, 0.1)
Expected output:
0.810419
Example 3: Upper-tail variance credible bound
Inputs:
| shape | scale | prob |
|---|---|---|
| 9 | 15 | 0.95 |
Excel formula:
=INVGAMMA_POST_Q(9, 15, 0.95)
Expected output:
3.19473
Example 4: Quantile with fractional shape parameter
Inputs:
| shape | scale | prob |
|---|---|---|
| 3.4 | 4.2 | 0.75 |
Excel formula:
=INVGAMMA_POST_Q(3.4, 4.2, 0.75)
Expected output:
2.05207
Python Code
from scipy.stats import invgamma as scipy_invgamma
def invgamma_post_q(shape, scale, prob):
"""
Compute an inverse-Gamma posterior quantile.
See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.invgamma.html
This example function is provided as-is without any representation of accuracy.
Args:
shape (float): Inverse-Gamma shape parameter (positive).
scale (float): Inverse-Gamma scale parameter (positive).
prob (float): Target cumulative probability level in [0, 1].
Returns:
float: Inverse-Gamma posterior quantile for the requested probability level.
"""
try:
shape = float(shape)
scale = float(scale)
prob = float(prob)
if shape <= 0 or scale <= 0:
return "Error: shape and scale must be positive"
if prob < 0 or prob > 1:
return "Error: prob must be between 0 and 1"
return float(scipy_invgamma.ppf(prob, a=shape, scale=scale))
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Inverse-Gamma shape parameter (positive).
Inverse-Gamma scale parameter (positive).
Target cumulative probability level in [0, 1].