liveBook · Manning

Bayesian statistics

As explained in Math and Architectures of Deep Learning

A parameter-estimation approach that combines observed data with a prior distribution to produce a posterior distribution over unknown quantities.

Bayesian statistics estimates unknown quantities by combining a likelihood from observed data with a prior belief. Bayes’ theorem turns them into a posterior distribution: p(θ|X) is proportional to p(X|θ)p(θ). The prior matters most with little data; as data grows, the likelihood increasingly dominates. section 6.6.1 section 13.11

Choose a likelihood family for the data, then express its parameters as uncertain variables. A Gaussian likelihood, for example, may use a Gaussian prior for an unknown mean, a gamma prior for unknown precision, or a normal-gamma prior when both mean and precision are unknown. Conjugate priors keep the posterior in a tractable distribution family. section 13.3 section 13.6.1 section 13.7.2

Bayesian parameter estimation distinguishes these quantities:

  • Likelihood p(X|θ): how probable the observed training data is under parameters θ; for independent instances, it is the product of per-instance probabilities. section 6.6.1
  • Prior p(θ): beliefs or constraints on parameters before using the data, such as favoring smaller-magnitude parameter vectors. section 6.6.1
  • Posterior p(θ|X): the updated uncertainty over parameters after combining prior and likelihood. section 13.11
  • MAP estimate: the parameter value at the maximum of the posterior; unlike MLE, it incorporates prior information. section 13.11

Estimating heights from a small sample

Model adult female heights as Gaussian when only five samples are available. A normal-gamma prior informed by a neighboring population supplies beliefs about mean and variation; updating it with the samples yields posterior MAP estimates for mean and standard deviation, then a fitted distribution for range probabilities. section 13.8 section 13.8.2

The same update supports unsupervised classification with Gaussian mixture models. After fitting mixture parameters, compute p(Z=k|X=x) for each cluster and assign an input to the cluster with the largest posterior probability; variance controls how tolerant each cluster is of distance from its mean. section 6.9.3

Listing 13.5 PyTorch- Computing posterior probability using Bayesian inference
prior_dist = NormalGamma(150, 100, 10.5, 810)                   #1

posterior_dist = inference_unknown_mean_variance(X, prior_dist) #2

map_mu, map_precision =  posterior_dist.mode                    #3

map_std = math.sqrt(1 / map_precision)                          #4

map_dist = Normal(map_mu, map_std)                              #5

A short PyTorch workflow constructs a normal-gamma prior, computes its posterior from samples, extracts MAP mean and precision, and creates the fitted normal distribution. section 13.8.2

How Math and Architectures of Deep Learning covers it

How deep it goes
Derives Gaussian, gamma, Wishart, and normal-gamma posterior updates, including multivariate estimation and PyTorch implementations.
Examples
Uses Gaussian height samples, Gaussian mixture classification, and univariate and multivariate Gaussian parameter estimation.
What it assumes
Builds from conditional probability and Bayes’ theorem before parameter-estimation procedures.
What you can do after
Apply it via PyTorch to update Gaussian-family posteriors and obtain MAP parameter estimates.
How it connects
Connects conditional probability, likelihood, priors, posteriors, MAP estimation, MLE, Gaussian mixture models, entropy, and KL divergence.

Also explained in

Compare how 8 books explain bayesian statistics →

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.