Search

Search papers and lessons

Exponential Family

Level 3 · 11 min read

An exponential family is a class of distributions that share one template, so maximum likelihood estimation reduces to matching the model's averages of a few summary statistics to the data's averages.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Discrete math
  • Inference
  • Sign in to see your progress

TL;DR

Many of the distributions you already know are written with the same template: a fixed base function, times the exponential of a dot product between a set of natural parameters and a set of summary statistics, divided by a normaliser. The distributions that fit this template form the exponential family. Because they share one shape, estimation is unusually clean. The maximum likelihood estimate is found by setting the model's average summary statistics equal to the data's average.

Where you'll see it: in the Bernoulli and softmax outputs of classifiers, in the conjugate priors of Bayesian models, and in the E-step of the EM algorithm.

Intuition

One recipe, many distributions

Think of a family of recipes. Each recipe counts some ingredients in the data, and each ingredient gets a dial that sets how strongly it counts. The counted ingredients are the sufficient statistics T(x)\mathbf{T}(x). The dials are the natural parameters η\boldsymbol{\eta}. A base factor h(x)h(x) says how likely each raw value is before any dial is turned, and a normaliser makes the final result add up to 1.

For a Bernoulli coin, the counted ingredient is simply whether the flip came up heads. For a Poisson count, it is the count itself. For a Gaussian with a known spread, it is the value itself. Each member of the family is one recipe with its own ingredients.

Why the template is worth having

When you fit a model to data, you want to know which features of the data matter. The template gives a strong answer. Every bit of information the data carries about the parameter sits in the sum of the sufficient statistics, plus the sample size. The order of the observations does not matter, and neither do the details that the statistics ignore. This is a lossless compression of the data, and it is why the family has such convenient formulas.

The shape also controls what the normaliser looks like. Its logarithm, called the log-partition function A(η)A(\boldsymbol{\eta}), is a smooth convex curve. Its slope is the average of the statistics, so once you know the curve you know the mean. The plot below shows this for a coin.

−4−3−2−10123401234natural parameter ηvalue
  • A(η), the log-partition
  • A′(η), the mean θ
For a Bernoulli coin, the log-partition A(η) is convex, and its slope A′(η) is the success probability θ. At η = 0 the slope is 0.5 and the curve sits at log 2 ≈ 0.693.

The math

Definition

Definition: Exponential family

A family of distributions p(x∣η)p(x \mid \boldsymbol{\eta}), indexed by a vector of natural parameters η\boldsymbol{\eta}, is an exponential family if its density (or mass function, for discrete xx) can be written as

p(x∣η)=h(x) exp⁡ ⁣(η⊤T(x)−A(η)),p(x \mid \boldsymbol{\eta}) = h(x)\,\exp\!\left(\boldsymbol{\eta}^\top \mathbf{T}(x) - A(\boldsymbol{\eta})\right),

where T(x)\mathbf{T}(x) is a fixed vector of sufficient statistics, h(x)≥0h(x) \ge 0 is a base measure that does not depend on η\boldsymbol{\eta}, and

A(η)=log⁡∫h(x) exp⁡ ⁣(η⊤T(x)) dxA(\boldsymbol{\eta}) = \log \int h(x)\,\exp\!\left(\boldsymbol{\eta}^\top \mathbf{T}(x)\right)\,dx

is the log-partition function. For discrete xx the integral becomes a sum.

Read the symbols in words. xx is one observation. η\boldsymbol{\eta} is the list of dials. T(x)\mathbf{T}(x) is the list of counted ingredients, and the dot product η⊤T(x)\boldsymbol{\eta}^\top \mathbf{T}(x) combines them with the dials. The term A(η)A(\boldsymbol{\eta}) is exactly the logarithm of the normaliser, so subtracting it makes the density integrate to 1. Its definition is the log of an integral, and the sum or integral runs over every possible value of xx.

Many textbooks write the family with the original parameter θ\boldsymbol{\theta} and a map η(θ)\boldsymbol{\eta}(\boldsymbol{\theta}). The form above, where η\boldsymbol{\eta} enters linearly, is called the canonical form, and it is the one that makes the algebra below work.

Three familiar members

Bernoulli. Take p(x∣θ)=θx(1−θ)1−xp(x \mid \theta) = \theta^x (1 - \theta)^{1 - x} for x∈{0,1}x \in \{0, 1\}. Take logs:

xlog⁡θ+(1−x)log⁡(1−θ)=xlog⁡θ1−θ+log⁡(1−θ).x \log\theta + (1 - x)\log(1 - \theta) = x \log\frac{\theta}{1 - \theta} + \log(1 - \theta).

Define η=log⁡θ1−θ\eta = \log\frac{\theta}{1-\theta}. Then θ/(1−θ)=eη\theta/(1-\theta) = e^{\eta}, so θ=1/(1+e−η)\theta = 1/(1+e^{-\eta}) and 1−θ=1/(1+eη)1 - \theta = 1/(1+e^{\eta}). Substituting, log⁡(1−θ)=−log⁡(1+eη)\log(1-\theta) = -\log(1+e^{\eta}). So

p(x∣η)=exp⁡ ⁣(η x−log⁡(1+eη)),p(x \mid \eta) = \exp\!\left(\eta\, x - \log(1 + e^{\eta})\right),

with h(x)=1h(x) = 1, T(x)=xT(x) = x, and A(η)=log⁡(1+eη)A(\eta) = \log(1 + e^{\eta}). The natural parameter η\eta is the log-odds, which is why logistic regression is built on this family.

Gaussian with known variance. For X∼N(μ,σ2)X \sim \mathcal{N}(\mu, \sigma^2) with σ2\sigma^2 fixed, expand the square in the exponent:

−(x−μ)22σ2=−x22σ2+μσ2 x−μ22σ2.-\frac{(x-\mu)^2}{2\sigma^2} = -\frac{x^2}{2\sigma^2} + \frac{\mu}{\sigma^2}\,x - \frac{\mu^2}{2\sigma^2}.

Set η=μ/σ2\eta = \mu/\sigma^2, T(x)=xT(x) = x, h(x)=exp⁡(−x2/(2σ2))/2πσ2h(x) = \exp(-x^2/(2\sigma^2))/\sqrt{2\pi\sigma^2}. Then μ2/(2σ2)=σ2η2/2\mu^2/(2\sigma^2) = \sigma^2\eta^2/2, so A(η)=σ2η2/2A(\eta) = \sigma^2\eta^2/2.

Poisson. p(k∣λ)=λke−λ/k!=1k!exp⁡(klog⁡λ−λ)p(k \mid \lambda) = \lambda^k e^{-\lambda}/k! = \frac{1}{k!}\exp(k\log\lambda - \lambda) for k=0,1,2,…k = 0, 1, 2, \dots. Set η=log⁡λ\eta = \log\lambda, T(k)=kT(k) = k, h(k)=1/k!h(k) = 1/k!. The normaliser is ∑k=0∞eηk/k!=exp⁡(eη)\sum_{k=0}^{\infty} e^{\eta k}/k! = \exp(e^{\eta}) (the series for the exponential function evaluated at eηe^{\eta}), so A(η)=eηA(\eta) = e^{\eta}.

Other members include the exponential, the gamma, the beta, the multinomial and the categorical distribution. The Student-t and the Cauchy are not members, for reasons we return to under tradeoffs.

Moments come from derivatives of A

The most useful fact is this. Differentiate 1=∫h(x)exp⁡(η⊤T(x)−A(η)) dx1 = \int h(x)\exp(\boldsymbol{\eta}^\top\mathbf{T}(x) - A(\boldsymbol{\eta}))\,dx with respect to η\boldsymbol{\eta}. The derivative of the exponent with respect to η\boldsymbol{\eta} is T(x)−∇A(η)\mathbf{T}(x) - \nabla A(\boldsymbol{\eta}), so

0=∫(T(x)−∇A(η)) p(x∣η) dx⟹∇A(η)=E[T(X)].0 = \int \bigl(\mathbf{T}(x) - \nabla A(\boldsymbol{\eta})\bigr)\,p(x \mid \boldsymbol{\eta})\,dx \quad\Longrightarrow\quad \nabla A(\boldsymbol{\eta}) = \mathbb{E}[\mathbf{T}(X)].

Differentiating once more gives ∇2A(η)=Cov[T(X)]\nabla^2 A(\boldsymbol{\eta}) = \mathrm{Cov}[\mathbf{T}(X)].

Check it on the Bernoulli. A′(η)=eη/(1+eη)=θA'(\eta) = e^\eta/(1+e^\eta) = \theta, which is the mean of xx. And A′′(η)=θ(1−θ)A''(\eta) = \theta(1-\theta), which is the variance of a Bernoulli. Both match.

Because a covariance matrix is positive semidefinite, AA is a convex function. That single fact drives the estimation results below.

Maximum likelihood by moment matching

Take nn independent observations x1,…,xnx_1, \dots, x_n. The log-likelihood is

ℓ(η)=∑i=1nlog⁡p(xi∣η)=η⊤(∑i=1nT(xi))−n A(η)+∑i=1nlog⁡h(xi).\ell(\boldsymbol{\eta}) = \sum_{i=1}^{n} \log p(x_i \mid \boldsymbol{\eta}) = \boldsymbol{\eta}^\top \Bigl(\sum_{i=1}^{n} \mathbf{T}(x_i)\Bigr) - n\,A(\boldsymbol{\eta}) + \sum_{i=1}^{n}\log h(x_i).

The data enter only through the sum ∑iT(xi)\sum_i \mathbf{T}(x_i) and the count nn. Set the gradient to zero:

∑i=1nT(xi)−n ∇A(η)=0⟹∇A(η^)=1n∑i=1nT(xi).\sum_{i=1}^{n} \mathbf{T}(x_i) - n\,\nabla A(\boldsymbol{\eta}) = 0 \quad\Longrightarrow\quad \nabla A(\hat{\boldsymbol{\eta}}) = \frac{1}{n}\sum_{i=1}^{n}\mathbf{T}(x_i).

The left side is the model's expected statistics. The right side is the observed average. The estimate is the setting that makes them equal. This is moment matching, and it is the maximum likelihood estimate. Since ℓ\ell is a concave function (the negative of a convex one, plus a linear term), any stationary point is the global maximum.

Conjugate priors

In Bayesian work, the family also gives a ready-made prior. A prior of the form p(η∣χ,ν)∝exp⁡(η⊤χ−νA(η))p(\boldsymbol{\eta} \mid \boldsymbol{\chi}, \nu) \propto \exp(\boldsymbol{\eta}^\top\boldsymbol{\chi} - \nu A(\boldsymbol{\eta})) is conjugate to the likelihood. After nn observations, the posterior has the same form with updated hyperparameters χ+∑iT(xi)\boldsymbol{\chi} + \sum_i \mathbf{T}(x_i) and ν+n\nu + n. Learning is just adding counts. For the Bernoulli, this is the Beta prior, where the success and failure counts are added to the prior's pseudo-counts.

Worked examples

Example
Bernoulli: five coin flips

Observed flips: 1, 0, 1, 1, 0. Here T(x)=xT(x) = x, so the data's average statistic is the sample proportion.

  1. Sum of statistics: ∑iT(xi)=1+0+1+1+0=3\sum_i T(x_i) = 1 + 0 + 1 + 1 + 0 = 3, and n=5n = 5.
  2. Average: 3/5=0.63/5 = 0.6.
  3. Match: ∇A=θ\nabla A = \theta, so θ^=0.6\hat\theta = 0.6.
  4. Natural parameter: η^=log⁡(0.6/0.4)=log⁡1.5≈0.405\hat\eta = \log(0.6/0.4) = \log 1.5 \approx 0.405.
  5. Interpretation: the estimate is the familiar sample proportion, reached through the template. The general recipe produced a result you could have guessed.
Example
Gaussian with known variance: three measurements

Measurements 2,4,62, 4, 6 from N(μ,1)\mathcal{N}(\mu, 1), so σ2=1\sigma^2 = 1. Here T(x)=xT(x) = x.

  1. Sum of statistics: 2+4+6=122 + 4 + 6 = 12, and n=3n = 3.
  2. For this family ∇A(η)=σ2η=μ\nabla A(\eta) = \sigma^2\eta = \mu, so matching gives μ^=12/3\hat\mu = 12/3.
  3. μ^=4\hat\mu = 4.
  4. Interpretation: the maximum likelihood estimate of a Gaussian mean is the sample mean. Only the sum of the values mattered, not their order.
Example
Poisson: email counts per hour

A mailbox receives 2, 0, 3 and 1 messages in four consecutive hours. Assume the counts are Poisson with rate λ\lambda, so T(k)=kT(k) = k.

  1. Sum of statistics: 2+0+3+1=62 + 0 + 3 + 1 = 6, and n=4n = 4.
  2. For this family ∇A(η)=eη=λ\nabla A(\eta) = e^{\eta} = \lambda, so matching gives λ^=6/4=1.5\hat\lambda = 6/4 = 1.5.
  3. Natural parameter: η^=log⁡1.5≈0.405\hat\eta = \log 1.5 \approx 0.405.
  4. Interpretation: about 1.5 messages per hour. Reordering the four counts would not change the estimate, because only ∑iT(xi)\sum_i T(x_i) and nn enter the likelihood.
Example
Sufficiency: two orderings, one likelihood

Two Bernoulli experiments each record three flips. Experiment A gives 1, 1, 0 and experiment B gives 0, 1, 1.

  1. Both have n=3n = 3.
  2. Both have ∑iT(xi)=2\sum_i T(x_i) = 2.
  3. The log-likelihood is η⋅2−3log⁡(1+eη)\eta \cdot 2 - 3\log(1 + e^{\eta}) for both.
  4. So the two likelihood curves are identical, and so is the MLE θ^=2/3\hat\theta = 2/3.
  5. Interpretation: the sufficient statistic keeps everything the parameter needs. The order of the flips is discarded without loss.

Tradeoffs and failure modes

The family is powerful because it is narrow. Whenever a model leaves it, the clean estimation results go away.

SituationProblemBetter choice
Mixture of two or more GaussiansNot an exponential family; one bell cannot have two humps, and the likelihood has no single summaryExpectation-maximization, which applies the exponential-family formulas to the complete data
Uniform on [0,θ][0, \theta]The support depends on the parameter, so the template (and its moment-matching result) does not applyWork directly with the maximum observed value, which is sufficient here
Student-t or Cauchy noiseThe density cannot be written in the canonical form, so there is no moment-matching equationNumerical maximum likelihood or robust losses
Models with an intractable normaliser (large Ising or energy-based models)A(η)A(\boldsymbol{\eta}) has no closed form, so E[T]\mathbb{E}[\mathbf{T}] cannot be computed exactlySampling (Markov chain Monte Carlo) or variational approximations
Mixing up natural and mean parametersPlugging μ\mu or θ\theta into η\eta gives wrong answersAlways convert with the link function first

Two warnings in practice:

  • Canonical form is required for the clean moment-matching result. If you fit a non-canonical parametrisation, the gradient picks up a chain-rule factor, and a textbook shortcut will silently give the wrong equation.
  • Being in the family is a claim you should check. Plotting a histogram does not confirm it. Check that the support does not depend on the parameter, and that the statistic is a fixed-length sum.

History

Ronald Fisher developed the idea of a sufficient statistic in the 1920s, as a way to say that some summaries of data keep all the information about a parameter. In the mid-1930s, Georges Darmois, Bernard Koopman and Edwin Pitman each worked out, independently, that the families with a fixed-length sufficient statistic (and a support that does not depend on the parameter) are exactly the exponential families. This result is now called the Pitman–Koopman–Darmois theorem. The name "exponential family" came into common use later in the twentieth century.

The family caught on for two reasons. First, it unified many separate distributions into one theory with one estimation rule. Second, in 1972 John Nelder and Robert Wedderburn used it to define generalised linear models, which include logistic and Poisson regression and are still used across the sciences. Lawrence Brown's 1986 monograph gave the full mathematical treatment, and Martin Wainwright and Michael Jordan showed in 2008 how the same convex log-partition function links probabilistic graphical models to variational inference.

Check yourself

QuestionWhat is the log-partition function A(η)A(\boldsymbol{\eta}), and what is its derivative?Show answer

A(η)A(\boldsymbol{\eta}) is the log of the integral (or sum) of h(x)exp⁡(η⊤T(x))h(x)\exp(\boldsymbol{\eta}^\top\mathbf{T}(x)) over all xx. Subtracting it from the exponent makes the density integrate to 1, so it is the logarithm of the normaliser. Its gradient is the expected value of the sufficient statistics, ∇A(η)=E[T(X)]\nabla A(\boldsymbol{\eta}) = \mathbb{E}[\mathbf{T}(X)].

QuestionFive independent Poisson counts are 3, 1, 2, 0 and 4. Find the maximum likelihood estimate of the rate λ\lambda and of the natural parameter η\eta.Show answer

The sum of the statistics is 3+1+2+0+4=103 + 1 + 2 + 0 + 4 = 10, and n=5n = 5. Matching ∇A=eη=λ\nabla A = e^{\eta} = \lambda to the sample average gives λ^=10/5=2\hat\lambda = 10/5 = 2. The natural parameter is η^=log⁡2≈0.693\hat\eta = \log 2 \approx 0.693.

QuestionWhy does the maximum likelihood estimate of an exponential-family model depend on the data only through the sum of the sufficient statistics and the sample size?Show answer

The log-likelihood is a linear function of η\boldsymbol{\eta} with coefficient ∑iT(xi)\sum_i \mathbf{T}(x_i), minus nn times A(η)A(\boldsymbol{\eta}), plus a term that does not depend on η\boldsymbol{\eta}. Every other feature of the data is absent from the likelihood. This is what sufficiency means for this family.

QuestionA sensor reports whether a light is on (1) or off (0) on 20 trials, and it is on in 14 of them. Which family models this, and what is the maximum likelihood estimate of the on-probability θ\theta and of the natural parameter η\eta?Show answer

It is a Bernoulli model, which is an exponential family with T(x)=xT(x) = x. The sample average is 14/20=0.714/20 = 0.7, so θ^=0.7\hat\theta = 0.7. The natural parameter is the log-odds η^=log⁡(0.7/0.3)≈0.847\hat\eta = \log(0.7/0.3) \approx 0.847. The same estimate would follow from any ordering of the 20 trials, because only the count of ons matters.

Sources