InverseGamma
DistributionInverseGamma(concentration: Tensor | float, rate: Tensor | float, validate_args: bool | None = None)Inverse-Gamma distribution on .
Distribution of the reciprocal of a Gamma random variable: if then . Widely used as the conjugate prior for the variance parameter of a Normal distribution with known mean, and as a prior on positive scale parameters more generally.
Parameters
Notes
Probability density on :
Moments (when defined):
Mode: .
Conjugacy: with a likelihood and known mean , the posterior over is again Inverse-Gamma with updated parameters , .
Because Lucid's lucid.distributions.Gamma sampler is
rejection-based, has_rsample is False here and
sample returns detached samples obtained by reciprocating
a Gamma draw.
Examples
>>> import lucid
>>> from lucid.distributions import InverseGamma
>>> d = InverseGamma(concentration=3.0, rate=2.0)
>>> d.mean # β / (α - 1) = 1.0
tensor(1.)
>>> d.sample((4,)).shape
(4,)Used by 2
Constructors
1__init__
→None__init__(concentration: Tensor | float, rate: Tensor | float, validate_args: bool | None = None)Properties
3Instance methods
4Cumulative distribution function of the inverse-Gamma distribution.
the regularized upper incomplete gamma
(lucid.special.gammaincc) — is
Gamma(alpha, beta), and is
. Evaluated as itself, not as
, so the small left tail keeps its relative precision.
Returns probabilities in ; 0 at and below 0.
Raises
NotImplementedErrorbackward, when concentration requires a gradient,
as in the reference framework.Examples
>>> InverseGamma(concentration=1.0, rate=1.0).cdf(lucid.tensor(1.0)) # 1/e
tensor(0.3679)α + log β + log Γ(α) − (1 + α) · ψ(α).
Sample by taking the reciprocal of a Gamma sample.