liveBook · Manning

Precision

As explained in Math and Architectures of Deep Learning

The precision parameter in the normal-gamma distribution.

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

How Math and Architectures of Deep Learning covers it

How deep it goes
Derives gamma and normal-gamma posterior updates, MAP estimates, and PyTorch counterparts, while deferring gamma details to an appendix.
Examples
Uses Gaussian data with known or unknown mean, gamma posterior formulas, and PyTorch Bayesian estimation listings.
What it assumes
Assumes Gaussian likelihoods and Bayesian estimation, while introducing inverse variance, gamma conjugacy, and normal-gamma structure.
What you can do after
Apply precision through gamma or normal-gamma posterior updates and implement Bayesian Gaussian estimation in PyTorch.
How it connects
Connects precision to variance, Gaussian likelihoods, gamma distributions, conjugate priors, normal-gamma distributions, MAP estimation, and maximum likelihood.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math and Architectures of Deep Learning. The section links point to the parts of the book it draws on.