§3.9.2–3.9.6Multinoulli · Gaussian · Exponential & Laplace · Dirac & Empirical · Mixtures

Part I DL pp. 62–66 · ~6 min read

  • multinoulli distribution
  • gaussian distribution
  • precision
  • central limit theorem
  • laplace distribution
  • empirical distribution
  • mixture distribution
  • latent variable
  • gaussian mixture model
  • prior probability
  • posterior probability

§3.9.2 The multinoulli distribution

The multinoulli (categorical) distribution handles one discrete variable with kk finite states, parametrized by p[0,1]k1\boldsymbol{p} \in [0,1]^{k-1} — the last state’s probability is whatever remains, 11p1 - \boldsymbol{1}^\top\boldsymbol{p} (so we must keep 1p1\boldsymbol{1}^\top\boldsymbol{p} \le 1). States are usually categories with no numeric value, so expectations and variances of multinoulli variables are rarely needed.

Multinoulli over 3 categories — only k−1 = 2 parameters are free
0.57P(x)cat0.50dog0.30bird0.20

only k−1 = 2 parameters are free; the last state gets what remains: p₃ = 1 − p₁ − p₂ = 0.20

Bernoulli and multinoulli can describe any distribution over their domains — not because they are powerful, but because their domains are simple enough to enumerate. Continuous variables have uncountably many states: any small-parameter description must impose real limits.

§3.9.3 The Gaussian distribution

The most-used distribution over the reals — the normal or Gaussian distribution :

Term by term

N(x;μ,σ2)=12πσ2exp(12σ2(xμ)2)\mathcal{N}(x; \mu, \sigma^2) = \sqrt{\frac{1}{2\pi\sigma^2}}\, \exp\left(-\frac{1}{2\sigma^2}(x - \mu)^2\right)
μ\muthe location of the central peak — and the mean, E[x] = μreal
σ\sigmastandard deviation: the width of the peak; variance is σ²; inflection points sit at μ ± σreal > 0
1/(2πσ2)\sqrt{1/(2\pi\sigma^2)}the normalizer that makes the area exactly 1constant in x
exp(2)\exp(-\cdot^2)the bell: quadratic penalty for straying from μ, exponentiatedshape term
Fig 3.1 (interactive) — the bell curve; watch the inflection points track μ ± σ
0.67p(x)-4.00.04.0

peak at x = μ = 0.0; inflection points at μ ± σ; precision β = 1/σ² = 1.00

Evaluating the PDF squares and inverts σ\sigma each time; when evaluating repeatedly with different parameters, the precision β=1/σ2(0,)\beta = 1/\sigma^2 \in (0, \infty) parametrization N(x;μ,β1)=β/2πe12β(xμ)2\mathcal{N}(x; \mu, \beta^{-1}) = \sqrt{\beta/2\pi}\, e^{-\frac{1}{2}\beta(x-\mu)^2} is cheaper.

Why the Gaussian is the default

Two reasons. (1) The central limit theorem : sums of many independent random variables are approximately normal, so complicated systems are successfully modeled as normally distributed noise even when their parts are structured. (2) Among all distributions with a given variance, the normal encodes the maximum uncertainty — it injects the least prior knowledge into a model (made rigorous in §19.4.2).

In Rn\mathbb{R}^n it becomes the multivariate normal, parametrized by a positive definite symmetric covariance Σ\boldsymbol{\Sigma}:

Term by term

N(x;μ,Σ)=1(2π)ndet(Σ)exp(12(xμ)Σ1(xμ))\mathcal{N}(\boldsymbol{x}; \boldsymbol{\mu}, \boldsymbol{\Sigma}) = \sqrt{\frac{1}{(2\pi)^n \det(\boldsymbol{\Sigma})}} \exp\left(-\frac{1}{2}(\boldsymbol{x} - \boldsymbol{\mu})^\top \boldsymbol{\Sigma}^{-1} (\boldsymbol{x} - \boldsymbol{\mu})\right)
μ\boldsymbol{\mu}the (now vector-valued) meann×1
Σ\boldsymbol{\Sigma}the covariance matrix of the distribution (ch. 2 machinery: positive definite, symmetric)n×n
Σ1\boldsymbol{\Sigma}^{-1}inverting Σ per evaluation is costly — the precision MATRIX β avoids itn×n
det(Σ)\det(\boldsymbol{\Sigma})the volume factor from §2.11 appears in the normalizerscalar

Common simplifications: diagonal covariance, or the isotropic Gaussian (covariance = scalar × identity).

Worked example — one density value

Standard normal (μ=0\mu = 0, σ=1\sigma = 1) at x=0x = 0: N(0;0,1)=1/2π0.399\mathcal{N}(0; 0, 1) = \sqrt{1/2\pi} \approx 0.399. At x=2x = 2: 0.399e20.0540.399 \cdot e^{-2} \approx 0.054 — about 7× less dense two standard deviations out. (Check both against the widget.)

§3.9.4 Exponential and Laplace

Deep learning often wants a sharp point at x=0x = 0 — the exponential distribution p(x;λ)=λ1x0eλxp(x; \lambda) = \lambda\,\boldsymbol{1}_{x \ge 0}\,e^{-\lambda x} (the indicator function zeroes all negative xx). To put the sharp peak at an arbitrary μ\mu, use the Laplace distribution Laplace(x;μ,γ)=12γexμ/γ\mathrm{Laplace}(x; \mu, \gamma) = \frac{1}{2\gamma} e^{-|x-\mu|/\gamma}:

Laplace — a movable sharp peak (compare the kink at μ with the Gaussian’s smooth top)
0.93p(x)-4.00.04.0

a sharp peak at an ARBITRARY point μ = 0.0 — the movable cousin of the exponential

§3.9.5 Dirac and empirical distributions

To concentrate all mass at one point, use the Dirac delta function: p(x)=δ(xμ)p(x) = \delta(x - \mu) — zero everywhere except μ\mu, yet integrating to 1. It is not an ordinary function but a generalized function: the limit of functions putting ever less mass everywhere else. Its main job is building the empirical distribution of a dataset:

Term by term

p^(x)=1mi=1mδ(xx(i))\hat{p}(\boldsymbol{x}) = \frac{1}{m} \sum_{i=1}^m \delta(\boldsymbol{x} - \boldsymbol{x}^{(i)})
δ(xx(i))\delta(\boldsymbol{x} - \boldsymbol{x}^{(i)})an infinitely narrow, infinitely tall spike at training point igeneralized fn
1/m1/meach of the m data points carries equal massscalar
p^\hat{p}the distribution you actually SAMPLE from when training on this dataset — and the density that maximizes the likelihood of the data (§5.5)distribution
Empirical distribution — m equal spikes of mass 1/m at the data points (discrete view)
0.57P(x)-1.60.20-0.90.20-0.20.200.40.201.10.20

a Dirac spike of mass 1/m = 0.200 at each of the m data points — training samples FROM this

(For discrete variables no Dirac is needed — the empirical distribution is just a multinoulli with probabilities equal to empirical frequencies.)

§3.9.6 Mixtures of distributions

Richer distributions come from combining simple ones. A mixture distribution picks, on each trial, which component generates the sample:

Term by term

P(x)=iP(c=i)P(xc=i)P(\mathrm{x}) = \sum_i P(\mathrm{c} = i)\, P(\mathrm{x} \mid \mathrm{c} = i)
c\mathrm{c}the component identity — a multinoulli, and our first LATENT variable: never observed directlydiscrete, hidden
P(c=i)P(\mathrm{c} = i)the PRIOR αᵢ — the model’s belief about c before seeing xmultinoulli
P(xc=i)P(\mathrm{x} \mid \mathrm{c} = i)component i’s own distribution over xper-component

The empirical distribution was already a mixture — one Dirac component per example. The latent variable cc relates to xx through P(x,c)=P(xc)P(c)P(x, c) = P(x|c)P(c); after observing xx, the updated belief P(cx)P(c|x) is the posterior (versus the prior P(c)P(c)) — vocabulary that chapters 5, 13 and 16–20 use constantly.

The star example: the Gaussian mixture model , components p(xc=i)=N(x;μ(i),Σ(i))p(x|c=i) = \mathcal{N}(x; \mu^{(i)}, \Sigma^{(i)}) — a universal approximator of densities (any smooth density, to any nonzero error, with enough components):

A 2-component Gaussian mixture — α is the prior; slide μ₂ into μ₁ and the modes fuse
0.67p(x)-4.50.04.5

P(x) = α·N(x; μ₁, σ²) + (1−α)·N(x; μ₂, σ²): the prior α = P(c=1) = 0.50 picks the component; merge the means and the modes fuse

isotropicΣ = σ²I: equal variance every directiondiagonalper-axis variances, axis-alignedfull-rankvariance along any basis

Fig 3.2 (recreated) — three GMM components with increasingly flexible covariance constraints. Constraints can also be shared across components (Σ⁽ⁱ⁾ = Σ ∀i).

Next: the functions that parametrize these distributions — sigmoid, softplus, Bayes’ rule and information theory.

Check yourself — the distribution zoo

1.Why does a k-state multinoulli use only k−1 parameters?

2.The book gives two reasons the Gaussian is the default distribution over reals. Which pair?

3.When is the precision parametrization β = 1/σ² (or the precision matrix) preferred?

4.What makes the Dirac delta 'not an ordinary function', and why do we need it?

5.In the GMM widget, you slide μ₂ until it equals μ₁. Predict the curve, and name the latent variable.

5 questions