Precision, written λ, is the inverse of Gaussian variance: λ = 1/σ². Expressing a Gaussian with precision gives p(x|μ, λ) = 𝒩(x; μ, 1/√λ), so larger precision represents smaller variance. section 13.6.1 section 13.7.2
In a normal-gamma model, precision is a random variable paired with the mean μ. The prior is a gamma distribution, and multiplying it by the Gaussian likelihood produces another normal-gamma posterior when both μ and λ are unknown. section 13.7.1 section 13.7.2
Bayesian estimation uses precision to update uncertainty about a Gaussian data distribution:
- With known mean, assign λ a gamma prior with parameters α₀ and β₀; conjugacy keeps the posterior in the gamma family. section 13.6 section 13.5
- For training data X, update the gamma parameters to αₙ and βₙ, then estimate precision through the posterior mode λMAP = (αₙ − 1)/βₙ. section 13.6.1
- As data volume grows, the MAP estimate approaches the maximum-likelihood estimate; with no data, the prior determines the estimate. section 13.6.1
Known mean, unknown variance
Given observations X and a known mean μ, compute the sample standard deviation, update αₙ = n/2 + α₀ and βₙ = nσMLE²/2 + β₀, construct a gamma posterior for λ, and recover σMAP from λMAP = 1/σMAP². section 13.6.1
Listing 13.2 PyTorch- Bayesian estimation with unknown variance, known mean
import torch
def inference_unknown_variance(X, prior_dist):
sigma_mle = torch.std(X)
n = X.shape[0]
alpha_0 = prior_dist.concentration
beta_0 = prior_dist.rate #1
alpha_n = n / 2 + alpha_0
beta_n = n / 2 * sigma_mle ** 2 + beta_0 #2
posterior_dist = torch.Gamma(alpha_n, beta_n)
return posterior_dist
Use the PyTorch listing to connect the gamma posterior update for precision with executable computation. section 13.6.1
