Skip to main content
© 2026 ePowerAI. All rights reserved.
CoursesContact
eAI
CoursesContact
Week 12: Exponential Families (lite)
Prob & Stats
01Week 1: Probability Spaces and Events
02Week 2: Random Variables and Distributions
03Week 3: Expectation, Variance, and Covariance
04Week 4: Conditioning and Independence
05Week 5: Bayes' Rule and Generative Classification
06Week 6: Multivariate Gaussians
07Week 7: Laws of Large Numbers and the CLT
08Week 8: Point Estimation — Maximum Likelihood
09Week 9: Bayesian Estimation and MAP
10Week 10: Bias, Variance, and Uncertainty
11Week 11: Information Theory for ML
12Week 12: Exponential Families (lite)
13Week 13: Graphical Models (lite)
14Week 14: Capstone — Probabilistic Language of ML
Week 12· Prob & Stats· ML interface20 min read

Week 12: Exponential Families (lite)

✦Learning Outcomes
  • Write the exponential family form p(x∣η)=h(x)exp⁡(η⋅T(x)−A(η))p(x \mid \eta) = h(x) \exp(\eta \cdot T(x) - A(\eta))p(x∣η)=h(x)exp(η⋅T(x)−A(η))
  • Identify natural parameter η\etaη, sufficient statistic TTT, log-partition AAA
  • Place Bernoulli and univariate Gaussian in this form
  • Explain why conjugate priors and moment matching feel natural here
◆Prerequisites

Required: Weeks 2, 8–9 (distributions, MLE, MAP/Bayesian), Week 11 (entropy — log-partition A(η)A(\eta)A(η) is related to the cumulant generating function).

Use: Exponential families unify the distributions you already know under a single algebraic template. This unlocks general results about MLE, conjugacy, and maximum entropy that apply to all of them at once.

One Form to Rule Them#

Many of the most important distributions in ML — Bernoulli, Binomial, Poisson, Gaussian, Beta, Dirichlet, Categorical, Gamma — share a common algebraic structure called the exponential family:

p(x∣η)=h(x)exp⁡ ⁣(η⋅T(x)−A(η)).p(x \mid \eta) = h(x) \exp\!\big(\eta \cdot T(x) - A(\eta)\big).p(x∣η)=h(x)exp(η⋅T(x)−A(η)).

The four components:

| Symbol | Name | Role | |---|---|---| | η\etaη | Natural parameter (canonical parameter) | The parameter in the "natural" coordinate system | | T(x)T(x)T(x) | Sufficient statistic | Summarises all information in xxx needed to estimate η\etaη | | A(η)A(\eta)A(η) | Log-partition function (log-normaliser) | Ensures the density integrates/sums to 1 | | h(x)h(x)h(x) | Base measure | The part that does not depend on η\etaη |

The log-partition is not arbitrary — it is determined by the requirement that ppp integrates to 1:

A(η)=log⁡∫h(x)exp⁡(η⋅T(x)) dx.A(\eta) = \log \int h(x) \exp(\eta \cdot T(x))\, dx.A(η)=log∫h(x)exp(η⋅T(x))dx.

Why exponential families matter in ML:

  • MLE is convex in η\etaη: the log-likelihood η⋅∑T(xi)−nA(η)\eta \cdot \sum T(x_i) - n A(\eta)η⋅∑T(xi​)−nA(η) is concave in η\etaη, so finding the MLE is a convex optimisation problem.
  • Sufficient statistics of fixed size: regardless of sample size nnn, you only need the ddd-dimensional vector ∑T(xi)\sum T(x_i)∑T(xi​) to compute the MLE.
  • Conjugate priors exist naturally in the same family.
  • Maximum entropy property: among all distributions with a given expected sufficient statistic E[T(X)]\mathbb{E}[T(X)]E[T(X)], the exponential family member has maximum entropy.

Bernoulli and Gaussian as Examples#

Bernoulli in exponential family form#

The Bernoulli PMF is p(x)=px(1−p)1−xp(x) = p^x (1-p)^{1-x}p(x)=px(1−p)1−x for x∈{0,1}x \in \{0, 1\}x∈{0,1}. Rewrite:

p(x)=exp⁡ ⁣(xlog⁡p+(1−x)log⁡(1−p))=exp⁡ ⁣(xlog⁡p1−p+log⁡(1−p)).p(x) = \exp\!\big(x \log p + (1-x) \log(1-p)\big) = \exp\!\left(x \log\frac{p}{1-p} + \log(1-p)\right).p(x)=exp(xlogp+(1−x)log(1−p))=exp(xlog1−pp​+log(1−p)).

Read off the components:

  • Natural parameter: η=log⁡p1−p\eta = \log\frac{p}{1-p}η=log1−pp​ (the log-odds or logit).
  • Sufficient statistic: T(x)=xT(x) = xT(x)=x.
  • Log-partition: A(η)=−log⁡(1−p)=log⁡(1+eη)A(\eta) = -\log(1-p) = \log(1 + e^\eta)A(η)=−log(1−p)=log(1+eη).
  • Base measure: h(x)=1h(x) = 1h(x)=1.

The log-partition A(η)=log⁡(1+eη)A(\eta) = \log(1 + e^\eta)A(η)=log(1+eη) is the softplus function — this is exactly the activation that appears in the binary cross-entropy loss.

Mean parameterisation: The mean is μ=E[X]=p\mu = \mathbb{E}[X] = pμ=E[X]=p. The relationship between natural parameter and mean is:

μ=A′(η)=eη1+eη=11+e−η(the sigmoid function).\mu = A'(\eta) = \frac{e^\eta}{1 + e^\eta} = \frac{1}{1 + e^{-\eta}} \quad\text{(the sigmoid function)}.μ=A′(η)=1+eηeη​=1+e−η1​(the sigmoid function).

Indeed, in GLMs and logistic regression, the sigmoid maps the linear predictor (natural parameter space) to the probability (mean parameter space). This is not a coincidence — it is the exponential family structure.

Gaussian (known variance) in exponential family form#

For X∼N(μ,σ2)X \sim \mathcal{N}(\mu, \sigma^2)X∼N(μ,σ2) with known σ2\sigma^2σ2:

p(x)=12πσ2exp⁡ ⁣(−(x−μ)22σ2)=12πσ2exp⁡ ⁣(−x22σ2)exp⁡ ⁣(μσ2x−μ22σ2).p(x) = \frac{1}{\sqrt{2\pi\sigma^2}} \exp\!\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) = \frac{1}{\sqrt{2\pi\sigma^2}} \exp\!\left(-\frac{x^2}{2\sigma^2}\right) \exp\!\left(\frac{\mu}{\sigma^2} x - \frac{\mu^2}{2\sigma^2}\right).p(x)=2πσ2​1​exp(−2σ2(x−μ)2​)=2πσ2​1​exp(−2σ2x2​)exp(σ2μ​x−2σ2μ2​).

Components:

  • η=μ/σ2\eta = \mu / \sigma^2η=μ/σ2
  • T(x)=xT(x) = xT(x)=x
  • A(η)=μ2/(2σ2)=η2σ2/2A(\eta) = \mu^2 / (2\sigma^2) = \eta^2 \sigma^2 / 2A(η)=μ2/(2σ2)=η2σ2/2
  • h(x)=12πσ2exp⁡(−x2/(2σ2))h(x) = \frac{1}{\sqrt{2\pi\sigma^2}} \exp(-x^2 / (2\sigma^2))h(x)=2πσ2​1​exp(−x2/(2σ2))

The mean parameter is A′(η)=ησ2=μA'(\eta) = \eta \sigma^2 = \muA′(η)=ησ2=μ (the identity link in linear regression).

Log-Partition and Moments#

A key property: derivatives of A(η)A(\eta)A(η) give moments of the sufficient statistic:

E[T(X)]=∇ηA(η),Cov(T(X))=∇η2A(η).\mathbb{E}[T(X)] = \nabla_\eta A(\eta), \qquad \mathrm{Cov}(T(X)) = \nabla_\eta^2 A(\eta).E[T(X)]=∇η​A(η),Cov(T(X))=∇η2​A(η).

The gradient of the log-partition is the mean of T(X)T(X)T(X); the Hessian is its covariance. This follows from differentiating under the integral sign in the definition of A(η)A(\eta)A(η).

Worked check — Bernoulli. A(η)=log⁡(1+eη)A(\eta) = \log(1 + e^\eta)A(η)=log(1+eη). Then:

A′(η)=eη1+eη=p=E[X],A′′(η)=eη(1+eη)2=p(1−p)=Var(X).A'(\eta) = \frac{e^\eta}{1 + e^\eta} = p = \mathbb{E}[X], \qquad A''(\eta) = \frac{e^\eta}{(1 + e^\eta)^2} = p(1-p) = \mathrm{Var}(X).A′(η)=1+eηeη​=p=E[X],A′′(η)=(1+eη)2eη​=p(1−p)=Var(X).

For maximum likelihood: Setting ∇ηℓ(η)=∑T(xi)−n∇A(η)=0\nabla_\eta \ell(\eta) = \sum T(x_i) - n \nabla A(\eta) = 0∇η​ℓ(η)=∑T(xi​)−n∇A(η)=0 gives:

∇A(η^)=1n∑i=1nT(xi).\nabla A(\hat \eta) = \frac{1}{n}\sum_{i=1}^n T(x_i).∇A(η^​)=n1​i=1∑n​T(xi​).

The MLE matches the theoretical moments of T(X)T(X)T(X) to the empirical moments of the data — moment matching. This is why MLE is often equivalent to solving Eθ[T(X)]=Tˉemp\mathbb{E}_\theta[T(X)] = \bar T_{\text{emp}}Eθ​[T(X)]=Tˉemp​.

Softmax / Categorical Pointer#

The Categorical distribution (multi-class Bernoulli) over kkk classes is also in the exponential family. The natural parameters form a (k−1)(k-1)(k−1)-dimensional vector (one class is the reference). The log-partition is the log-sum-exp:

A(η)=log⁡ ⁣(1+∑j=1k−1eηj).A(\eta) = \log\!\left(1 + \sum_{j=1}^{k-1} e^{\eta_j}\right).A(η)=log(1+j=1∑k−1​eηj​).

Its gradient is the softmax function — again, the activation function is determined by the exponential family structure. Multi-class cross-entropy loss with softmax output is exactly the negative log-likelihood of a categorical exponential family model.

Why ML Cares#

The exponential family scaffolding runs through much of modern ML:

  • Generalised Linear Models (GLMs): linear regression (Gaussian), logistic regression (Bernoulli), Poisson regression — all assume the response distribution is in an exponential family with a linear predictor in natural parameter space.
  • Variational inference: the mean-field update equations are particularly simple for conditionally conjugate exponential family models.
  • Maximum entropy principle: the exponential family is the unique max-entropy distribution for a given expected sufficient statistic — used in inverse RL and maximum entropy RL.
  • Information geometry: the Fisher information matrix is exactly ∇2A(η)\nabla^2 A(\eta)∇2A(η), and the natural gradient uses it to re-scale gradient steps.

This week is a "unification lens" — not a full GLM or information geometry course. The goal is to recognise the common structure so that when you see softmax, sigmoid, or moment-matching equations in research papers, you know where they come from.

Exercise · Fill in the blank

In the exponential family form p(x|η) = h(x) exp(η·T(x) − A(η)), what is the sufficient statistic T(x) for the Bernoulli distribution (x ∈ {0,1})?


Knowledge check#

Question 1 of 4

What is the role of the log-partition function A(η) in the exponential family?

It ensures the density integrates to 1 (normaliser)
It defines the sufficient statistic
It is the prior distribution
It is the likelihood function

Browser lab#

Plot A(η)A(\eta)A(η) and its derivative (mean parameter vs natural parameter) for the Bernoulli, showing the sigmoid link.

python · runs in browser
import numpy as np
import matplotlib.pyplot as plt

eta = np.linspace(-5, 5, 300)

A = np.log(1 + np.exp(eta))
dA = 1 / (1 + np.exp(-eta))
d2A = dA * (1 - dA)

fig, axes = plt.subplots(1, 3, figsize=(14, 4))

axes[0].plot(eta, A, "tab:blue", linewidth=2)
axes[0].set_title("Log-partition A(η) = log(1 + e^η)")
axes[0].set_xlabel("η (log-odds)"); axes[0].set_ylabel("A(η)")

axes[1].plot(eta, dA, "tab:orange", linewidth=2)
axes[1].set_title("Mean μ = A'(η) = σ(η)")
axes[1].set_xlabel("η (log-odds)"); axes[1].set_ylabel("μ (probability)")
axes[1].set_ylim(-0.05, 1.05)

axes[2].plot(eta, d2A, "tab:green", linewidth=2)
axes[2].set_title("Variance A''(η) = μ(1−μ)")
axes[2].set_xlabel("η (log-odds)"); axes[2].set_ylabel("Var")
axes[2].axhline(0.25, color="gray", linestyle="--", alpha=0.5, label="max=0.25")
axes[2].legend()

plt.tight_layout()
plt.show()

# Demonstrate MLE via moment matching
# Generate Bernoulli data with p=0.7
rng = np.random.default_rng(123)
n = 200
p_true = 0.7
data = rng.binomial(1, p_true, size=n)

p_hat = data.mean()
eta_hat = np.log(p_hat / (1 - p_hat))

print(f"True p = {p_true}, MLE p̂ = {p_hat:.4f}, η̂ = {eta_hat:.4f}")
print(f"A'(η̂) = {1/(1+np.exp(-eta_hat)):.4f} ≈ p̂ — moment matching confirmed")
← Previous
Week 11: Information Theory for ML
Next →
Week 13: Graphical Models (lite)
On this page
  • One Form to Rule Them
  • Bernoulli and Gaussian as Examples
  • Bernoulli in exponential family form
  • Gaussian (known variance) in exponential family form
  • Log-Partition and Moments
  • Softmax / Categorical Pointer
  • Why ML Cares
  • Knowledge check
  • Browser lab