The exponential family and sufficient statistics
Write distributions in exponential-family form and read off sufficient statistics and natural parameters.
The Bernoulli, Poisson, Gaussian, and many others look unrelated until you write them in one common algebraic form. The exponential family is that form[1]. Once a distribution is in it, the sufficient statistics, the mean, and the maximum-likelihood equations all fall out of the same template, which is why generalized linear models and much of classical statistics are built on it.
The canonical form
A family of distributions is an exponential family if its PMF or PDF can be written as[2]
where:
- is the sufficient statistic (a vector function of the data),
- is the natural parameter,
- is the log-partition function (the normalizer),
- is the base measure (no parameter dependence).
In canonical form the parameter is itself: . The whole parametric family is determined by the choice of , , and the resulting .
Bernoulli in exponential form
Start from and take the log inside an exponential:
Matching the template: , the natural parameter is the log-odds , the base measure is , and after inverting with the logistic . The logistic link of classification is not a convenient guess: it is the exponential-family natural parameter of the Bernoulli.
The log-partition generates moments
Differentiating with respect to the natural parameter produces the moments of the sufficient statistic. From , differentiate both sides with respect to :
Sketch. Differentiating the normalization identity and moving the derivative inside the integral brings down a factor ; setting the result to zero gives the mean. A second derivative gives the covariance. The log-partition is a moment generator built into the structure, and because its Hessian is a covariance, is convex in , which makes maximum-likelihood fitting a convex problem.
Sufficiency
is sufficient because the data enters the likelihood only through it: two datasets with the same produce the same likelihood and hence the same inference about . For i.i.d. samples, the likelihood depends on the data only through , so that sum (plus ) is all you need to store. This collapses an arbitrarily large dataset to a fixed-size summary without losing information about the parameter.
Check it on arrays
import numpy as np
rng = np.random.default_rng(7)
N = 2_000_000
# Bernoulli(q): verify A'(eta) = E[T(X)] = E[X] = q
q = 0.3
X = (rng.random(N) < q).astype(float)
eta = np.log(q / (1 - q)) # natural parameter (log-odds)
A = np.log(1 + np.exp(eta)) # log-partition
# A'(eta) = sigmoid(eta) should equal E[X]
sigmoid = lambda z: 1 / (1 + np.exp(-z))
print("A'(eta) =", round(sigmoid(eta), 4), " E[X] =", round(X.mean(), 4))
# A''(eta) = Var(T(X)) = q(1-q)
print("A''(eta) =", round(sigmoid(eta) * (1 - sigmoid(eta)), 4),
" Var(X) =", round(X.var(), 4))
# Sufficiency: likelihood depends on data only through sum(T(x)) = sum(x)
def loglik(eta, data):
return np.sum(eta * data - np.log(1 + np.exp(eta)))
data_a = X[:1000]
data_b = np.zeros(1000); data_b[:int(X[:1000].sum())] = 1.0 # same number of 1s
print("same sum -> same loglik:",
np.isclose(loglik(0.4, data_a), loglik(0.4, data_b)))The first and second derivatives of the log-partition reproduce the Bernoulli mean and variance, and two datasets with the same success count give identical likelihoods.
Exercises
Exercise 1. Write the Poisson PMF in canonical exponential form. Identify , the natural parameter , the base measure , and the log-partition .
Solution
Step 1. Take the log inside an exponential:
Step 2. Match the template . The factor outside the exponential is the base measure , the term multiplying is the natural parameter, and the remaining is the normalizer:
The substitution rewrites as a function of alone, as the canonical form requires.
Exercise 2. For the Poisson of Exercise 1, confirm that the log-partition generates the moments: show and , recovering the Poisson's equal mean and variance.
Solution
Step 1. From Exercise 1, . Differentiate once:
By the moment identity , this gives , the known Poisson mean.
Step 2. Differentiate again:
By , this gives . The same exponential reappears at every derivative, so mean and variance coincide: the equal-mean-and-variance fact is the log-partition being its own derivative.
Exercise 3 (code). Verify Exercise 2 numerically: sample from a Poisson, set , and confirm and match the empirical mean and variance.
Solution
import numpy as np
rng = np.random.default_rng(0)
N = 2_000_000
lam = 4.0
X = rng.poisson(lam, size=N)
eta = np.log(lam)
A_prime = np.exp(eta) # A'(eta) = e^eta
A_double = np.exp(eta) # A''(eta) = e^eta
print("A'(eta) =", round(A_prime, 4), " E[X] =", round(X.mean(), 4))
print("A''(eta) =", round(A_double, 4), " Var(X) =", round(X.var(), 4))
assert np.isclose(A_prime, X.mean(), atol=1e-2)
assert np.isclose(A_double, X.var(), atol=2e-2)Both derivatives equal , and the sampled mean and variance both land near 4, confirming the Poisson's defining equality through the log-partition.
The next lesson handles a different transformation question: what happens to a distribution when you pass the variable through a function.