normalinversegamma
Normal-Inverse-Gamma is a four-parameter family used as a conjugate prior for the mean and variance of a normal distribution. It models a joint distribution over the unknown mean mu and the precision tau (tau = 1/variance).
Parameterization and form. Let the parameters be mu0, lambda0 > 0, alpha0 > 0, beta0 > 0. If tau
Posterior updating. Suppose data x1, ..., xn are independent given mu and tau, with x_i ~ Normal(mu, tau^{-1}).
- mu_n = (lambda0 mu0 + n xbar) / lambda_n
- beta_n = beta0 + 0.5 * sum_i (x_i - xbar)^2 + (lambda0 n (xbar - mu0)^2) / (2 lambda_n)
Then the posterior is mu | tau, data ~ Normal(mu_n, (lambda_n tau)^{-1}) and tau | data ~ Gamma(alpha_n, beta_n). Marginally,
Applications. The Normal-Inverse-Gamma serves as a convenient prior in Bayesian inference for normal models with unknown