The Exponential Family
Our treatment of Bayesian statistics showed that certain likelihood-prior pairs such as Binomial-Beta and Normal-Normal produce posteriors in the same family as the prior. This is not a coincidence. These distributions all belong to the exponential family, a unified framework that encompasses many of the distributions used in statistics and machine learning, among them the Bernoulli, Poisson, Normal, Gamma, and Dirichlet distributions.
The exponential family is fundamental for three reasons:
- Conjugacy:
Every member possesses a natural conjugate prior, under which the Bayesian update reduces to adding the aggregated sufficient statistic and the sample size to the prior's hyperparameters. We state the conjugacy property without proof. - Efficiency:
Where the maximum likelihood estimate (MLE) exists in the interior of the natural parameter space, it is characterized by moment matching, which significantly simplifies the optimization landscape. - Geometry:
The log-partition function serves as a cumulant generating function, providing a direct bridge to Fisher information and information geometry.
An exponential family is a family of probability distributions parameterized by natural parameters (or canonical parameters) \(\eta \in \mathbb{R}^K\), with support over \(\mathcal{X} \subseteq \mathbb{R}^D\) such that \[ \begin{align*} p(x \mid \eta ) &= \frac{1}{Z(\eta)} h(x) \exp\{\eta^\top \mathcal{T}(x)\}\\\\ &= h(x) \exp\{\eta^\top \mathcal{T}(x) - A(\eta)\} \end{align*} \] where
- \(h(x)\) is a base measure (or carrier measure): a function depending only on \(x\), not on \(\eta\), and often equal to \(1\).
- \(\mathcal{T}(x) \in \mathbb{R}^K\) is the sufficient statistic vector. It is called sufficient because the likelihood depends on \(x\) only through \(\mathcal{T}(x)\). All information in \(x\) relevant to estimating \(\eta\) is captured by \(\mathcal{T}(x)\).
- \(Z(\eta)\) is the normalization function, defined so that \(p(x \mid \eta)\) integrates to one over the support, and we write \(A(\eta) = \log Z(\eta)\). The natural parameter \(\eta\) ranges over those vectors with \(Z(\eta) \lt \infty\).
Each exponential family is defined by different \(h(x)\) and \(\mathcal{T}(x)\).
The normalization function \(Z(\eta)\) is often referred to as the partition function in statistical physics and machine learning. In particular, the log-partition function: \[ A(\eta) = \log Z(\eta) \] is convex over the convex set \(\Omega = \{\eta \in \mathbb{R}^K : A(\eta) \lt \infty\}\), and is strictly convex when the family is minimal. That \(\Omega\) is convex and that \(A\) is convex on all of \(\Omega\) are consequences of Hölder's inequality, and the strict convexity of \(A\) on all of \(\Omega\) for a minimal family follows from its equality case. We take these facts for granted here. On the interior of \(\Omega\), which is convex because \(\Omega\) is, the convexity of \(A\), and its strict convexity when the family is minimal, also follow from the Hessian formula \(\nabla^2 A(\eta) = \operatorname{Cov}[\mathcal{T}(x)]\), as shown below in Theorem: Convexity of the Log-Partition Function on the Interior.
In the context of optimization and information geometry, \(A(\eta)\) acts as a convex potential function that links natural parameters to moment parameters.
An exponential family is said to be minimal if there is no nonzero \(\eta \in \mathbb{R}^K\) such that \[ \eta^\top \mathcal{T}(x) = \text{const} \] holds for \(h(x)\,dx\)-almost every \(x\), that is, for all \(x\) outside a set on which \(h\) integrates to zero (for a discrete support, with the integral replaced by a sum).
Equivalently, the components of the sufficient statistic vector \(\mathcal{T}(x)\) (along with the constant function \(1\)) are linearly independent as functions of \(x\), where two functions that agree \(h(x)\,dx\)-almost everywhere are identified. This property ensures the identifiability of the model. There is a unique, one-to-one mapping between the natural parameters \(\eta\) and the resulting probability distribution.
Math vs. ML Perspectives: Handling the Constant
In many machine learning contexts, the condition is simplified to \[ \eta^\top \mathcal{T}(x) = 0. \] This assumes that the bias (constant) term has already been absorbed into the sufficient statistic vector \(\mathcal{T}(x)\) by augmenting it with a constant \(1\).
However, in our canonical definition where the log-partition function \(A(\eta)\) and base measure \(h(x)\) are explicitly separated, we must use the more rigorous \(\text{const}\) condition. If \(\eta^\top \mathcal{T}(x)\) were a constant, that value would be absorbed by \(A(\eta)\), meaning multiple \(\eta\) values could represent the same distribution. A minimal representation prevents this redundancy, ensuring that the Fisher information matrix is positive definite at every interior point of \(\Omega\) and the optimization surface is well-behaved.
A common example of a non-minimal representation is the \(K\)-class multinomial distribution. Because the probabilities must sum to one (\(\sum p_i = 1\)), the natural parameters are over-specified. While we can work with this redundant form (as often done in Softmax regression), we can always reparameterize it into a minimal representation using \(K-1\) independent components to restore unique identifiability.
Let \(\eta = f(\phi)\), where \(\phi \in \mathbb{R}^M\) is some other possibly smaller set of parameters (\(M \leq K\)), and then \[ p(x \mid \phi ) = h(x) \exp\{ f(\phi)^\top \mathcal{T}(x) - A(f(\phi))\}. \] If \(M \lt K\) and the mapping \(\phi \to \eta\) is nonlinear, it is said to be a curved exponential family.
If \(\eta = f(\phi) = \phi\), the model is in canonical form and in addition, if \(\mathcal{T} =x\), we call it a natural exponential family (NEF): \[ p(x \mid \eta ) = h(x) \exp\{\eta^\top x - A(\eta)\}. \]
Finally, we define the moment parameters as follows: \[ m = \mathbb{E}[\mathcal{T}(x)] \in \mathbb{R}^K. \]
\[ \begin{align*} \operatorname{Ber}(x \mid \mu) &= \mu^x (1-\mu)^{1-x} \\\\ &= \exp\{x \log (\mu) + (1-x) \log (1-\mu)\}\\\\ &= \exp\{\mathcal{T}(x)^\top \eta\} \end{align*} \] where
- \(\mathcal{T}(x) = [\mathbb{1}\{x=1\}, \, \mathbb{1}\{x=0\}]\).
- \(\eta = [\log(\mu), \, \log(1-\mu)]\).
- \(\mu\) is the mean parameter.
In this representation, the components \(\mathbb{1}\{x=1\}\) and \(\mathbb{1}\{x=0\}\) of \(\mathcal{T}(x)\) satisfy \(\mathbb{1}\{x=1\} + \mathbb{1}\{x=0\} = 1\) for all \(x\) in the support, violating the minimality condition with the nonzero vector \(v = (1, 1)\). Consequently, shifting \(\eta\) by any multiple of \(v\) yields the same distribution, so \(\eta\) is not uniquely determined. To restore uniqueness, we use a minimal representation: \[ \operatorname{Ber}(x \mid \mu) = \exp\left\{x \log \left(\frac{\mu}{1-\mu}\right) + \log (1-\mu)\right\} \] where
- \(\mathcal{T}(x) = x\).
- \(\eta = \log \left(\frac{\mu}{1-\mu}\right)\).
- \(A(\eta) = -\log (1-\mu) = \log(1+ e^{\eta})\).
- \(h(x) = 1\).
The Bernoulli example reveals a fundamental connection to classification models. The mean parameter \(\mu\) can be recovered from the canonical parameter \(\eta\) via: \[ \mu = \sigma(\eta) = \frac{1}{1+e^{-\eta}}. \] Here \(\sigma(\cdot)\) is the logistic function.
A direct computation gives \[ \begin{align*} \frac{dA}{d \eta} &= \frac{d}{d\eta} \log(1+ e^{\eta}) \\\\ &= \frac{e^{\eta}}{1 + e^{\eta}} \\\\ &= \frac{1}{1+e^{-\eta}} \\\\ &= \mu. \end{align*} \]
In general, the log-partition function \(A(\eta)\) acts as the cumulant generating function for the sufficient statistics \(\mathcal{T}(x)\). In other words, the derivatives of \(A(\eta)\) generate all the cumulants of \(\mathcal{T}(x)\). The first two are particularly important.
Let \(\eta\) lie in the interior of \(\Omega = \{\eta \in \mathbb{R}^K : A(\eta) \lt \infty\}\). Then the gradient and Hessian of the log-partition function recover the first two cumulants of the sufficient statistic vector: \[ \nabla A(\eta) = \mathbb{E}[\mathcal{T}(x)], \quad \nabla^2 A(\eta) = \operatorname{Cov}[\mathcal{T}(x)]. \]
Write \(Z(\eta) = \int h(x) \exp\{\eta^\top \mathcal{T}(x)\}\,dx\), so that \(A(\eta) = \log Z(\eta)\). For \(\eta\) in the interior of \(\Omega\) the integral converges on a neighborhood of \(\eta\), and we take for granted that differentiation may be carried out under the integral sign there. Differentiating once gives \[ \begin{align*} \nabla A(\eta) &= \frac{\nabla Z(\eta)}{Z(\eta)} \\\\ &= \frac{1}{Z(\eta)} \int \mathcal{T}(x) h(x) \exp\{\eta^\top \mathcal{T}(x)\}\,dx \\\\ &= \int \mathcal{T}(x)\, p(x \mid \eta)\,dx = \mathbb{E}[\mathcal{T}(x)]. \end{align*} \] Differentiating a second time and applying the quotient rule to \(\nabla Z / Z\), \[ \begin{align*} \nabla^2 A(\eta) &= \frac{\nabla^2 Z(\eta)}{Z(\eta)} - \frac{\nabla Z(\eta)\,\nabla Z(\eta)^\top}{Z(\eta)^2} \\\\ &= \mathbb{E}[\mathcal{T}(x)\mathcal{T}(x)^\top] - \mathbb{E}[\mathcal{T}(x)]\,\mathbb{E}[\mathcal{T}(x)]^\top \\\\ &= \operatorname{Cov}[\mathcal{T}(x)]. \end{align*} \] The same computation applies verbatim to a discrete support, with the integral replaced by a sum over the support.
The first identity says the gradient of \(A\) returns the moment parameters \(m := \mathbb{E}[\mathcal{T}(x)]\). The second identity says the Hessian of \(A\) returns the covariance of the sufficient statistics. Minimality is what keeps this covariance matrix from degenerating.
Let \(\Omega = \{\eta \in \mathbb{R}^K : A(\eta) \lt \infty\}\). For every \(\eta\) in the interior of \(\Omega\) and every \(v \in \mathbb{R}^K\), \[ v^\top \nabla^2 A(\eta)\, v = \operatorname{Var}[v^\top \mathcal{T}(x)] \geq 0, \] the variance being taken under \(p(\cdot \mid \eta)\), and \(A\) is convex on that interior. If the family is minimal, then \(\nabla^2 A(\eta)\) is positive definite at every such \(\eta\), and \(A\) is strictly convex on that interior.
The quadratic form.
Pairing the second cumulant identity with
\(v\) on both sides, we obtain
\[
\begin{align*}
v^\top \nabla^2 A(\eta)\, v &= v^\top \operatorname{Cov}[\mathcal{T}(x)]\, v \\\\
&= \operatorname{Var}[v^\top \mathcal{T}(x)] \geq 0.
\end{align*}
\]
Assume the family is minimal, fix an interior \(\eta\) and a nonzero \(v \in \mathbb{R}^K\), and suppose the variance
were zero. Write \(m_v = \mathbb{E}[v^\top \mathcal{T}(x)]\). Then
\(\int (v^\top \mathcal{T}(x) - m_v)^2 \, p(x \mid \eta)\,dx = 0\) with a nonnegative measurable integrand, so by
the vanishing of nonnegative functions with zero integral
(applied with the sample space as the measure space and \(dx\) as the measure),
\((v^\top \mathcal{T}(x) - m_v)^2 \, p(x \mid \eta) = 0\) for almost every \(x\). For a discrete support, the integral
becomes a sum, and the conclusion holds at every point of the support. Since \((v^\top \mathcal{T}(x) - m_v)^2 \gt 0\) on
\(N = \{x : v^\top \mathcal{T}(x) \neq m_v\}\) and \(\exp\{\eta^\top \mathcal{T}(x) - A(\eta)\} \gt 0\), this says that
\(h = 0\) almost everywhere on \(N\), and by the converse direction of the same theorem, \(\int_N h(x)\,dx = 0\). Thus,
although \(v \neq 0\), \(v^\top \mathcal{T}(x) = m_v\) for \(h(x)\,dx\)-almost every \(x\), which minimality rules out.
Therefore \(v^\top \nabla^2 A(\eta)\, v \gt 0\).
Convexity along segments.
Let \(\eta_0 \neq \eta_1\) lie in the interior, put \(v = \eta_1 - \eta_0\),
and set \(g(t) = A(\eta_0 + t v)\). The interior of \(\Omega\) is convex. Indeed, if the balls of radius \(r\) about
\(\eta_0\) and \(\eta_1\) lie in \(\Omega\), then the convexity of \(\Omega\), noted above, puts the ball of radius \(r\)
about each point of the segment between them in \(\Omega\) as well. Hence \(\eta_0 + t v\) lies in the interior for every
\(t \in [0, 1]\). Since the interior is open, the same holds for \(t\) slightly below \(0\) and slightly above \(1\), so
there is an open interval \(J \supseteq [0, 1]\) on which \(\eta_0 + t v\) stays in the interior. Now \(g\) is the
log-partition function of the one-parameter exponential family with base measure
\(h(x) \exp\{\eta_0^\top \mathcal{T}(x)\}\) and sufficient statistic \(v^\top \mathcal{T}(x)\). Its partition function is
\(t \mapsto Z(\eta_0 + t v)\), so its natural parameter space is \(\{t : \eta_0 + t v \in \Omega\}\), which contains
\(J\) in its interior. Applying the
second cumulant identity to that family gives, for
\(t \in J\), \(g''(t) = \operatorname{Var}[v^\top \mathcal{T}(x)]\) under \(p(\cdot \mid \eta_0 + t v)\), which is
\(v^\top \nabla^2 A(\eta_0 + t v)\, v\). By the quadratic-form step, \(g''(t) \geq 0\), with strict inequality for a
minimal family (as \(v \neq 0\)). The route through the one-parameter family needs only the second cumulant identity, not
continuity of \(\nabla^2 A\).
Take the minimal case. By the mean value theorem applied to \(g'\), the derivative \(g'\) is strictly increasing on \(J\). For \(t \in (0, 1)\), the same theorem, now applied to \(g\) on \([0, t]\) and on \([t, 1]\), provides \(s_1 \in (0, t)\) and \(s_2 \in (t, 1)\) with \[ \begin{align*} \frac{g(t) - g(0)}{t} &= g'(s_1) \\\\ &\lt g'(s_2) \\\\ &= \frac{g(1) - g(t)}{1 - t}. \end{align*} \] Multiplying by \(t(1 - t) \gt 0\) and rearranging, we find \(g(t) \lt (1 - t)\, g(0) + t\, g(1)\), that is, \[ A\bigl((1 - t)\eta_0 + t \eta_1\bigr) \lt (1 - t) A(\eta_0) + t A(\eta_1). \] Without minimality the same argument, with \(g'' \geq 0\) and non-strict inequalities throughout, gives the corresponding non-strict inequality, so \(A\) is convex on the interior.
For a minimal family, the theorem makes the negative log-likelihood \(N A(\eta) - \eta^\top \mathcal{T}(\mathcal{D})\) (up to an \(\eta\)-independent constant) of the next section strictly convex on the interior of \(\Omega\), so it has at most one minimizer there. The MLE is therefore unique whenever it exists.
We now write two of the most widely used continuous distributions in machine learning in exponential family form.
\[ \begin{align*} \mathcal{N}(x \mid \mu, \, \sigma^2) &= \frac{1}{\sigma\sqrt{2\pi}}\exp \left\{-\frac{1}{2\sigma^2}(x - \mu)^2 \right\} \\\\ &= \frac{1}{\sqrt{2\pi}} \exp \left\{ \frac{\mu}{\sigma^2}x - \frac{1}{2\sigma^2}x^2 -\frac{1}{2\sigma^2}\mu^2 -\log \sigma \right\} \end{align*} \] where
- \(\mathcal{T}(x) = \begin{bmatrix}x \\ x^2 \end{bmatrix}\)
- \(\eta = \begin{bmatrix} \frac{\mu}{\sigma^2} \\ -\frac{1}{2\sigma^2} \end{bmatrix} \)
- \(A(\eta) = \frac{\mu^2}{2\sigma^2}+\log \sigma = -\frac{\eta_1^2}{4\eta_2}-\frac{1}{2}\log(-2\eta_2)\)
- \(h(x) = \frac{1}{\sqrt{2\pi}}\).
Also, the moment parameters are given by: \[ m = \begin{bmatrix} \mu \\ \mu^2 + \sigma^2 \end{bmatrix}. \] Note. If \(\sigma = 1\), the distribution becomes a natural exponential family such that
- \(\mathcal{T}(x) = x\)
- \(\eta = \mu\)
- \(A(\eta) = \frac{\mu^2}{2} = \frac{\eta^2}{2}\)
- \(h(x) = \frac{1}{\sqrt{2\pi}}\exp\{-\frac{x^2}{2}\} = \mathcal{N}(x \mid 0, 1)\), which is not constant.
The univariate case extends naturally to higher dimensions. The multivariate normal distribution can be rewritten in the information form, parameterized by the precision matrix \(\Lambda = \Sigma^{-1}\) and \(\xi = \Lambda\mu\), which converts directly into canonical exponential-family form (Example 3 below). This form plays a central role in graphical models and message passing algorithms.
\[ \begin{align*} \mathcal{N}(x \mid \mu, \Sigma) &= \frac{1}{(2\pi)^{\frac{D}{2}}\sqrt{\det(\Sigma)}} \exp \left\{ -\frac{1}{2}x^\top \Sigma^{-1}x + x^\top \Sigma^{-1}\mu -\frac{1}{2}\mu^\top \Sigma^{-1}\mu \right\}\\\\ &= c \exp\left \{x^\top \Sigma^{-1}\mu -\frac{1}{2}x^\top \Sigma^{-1}x \right\} \end{align*} \] where \[ c = \frac{\exp \left\{-\frac{1}{2}\mu^\top \Sigma^{-1} \mu\right\}}{(2\pi)^{\frac{D}{2}}\sqrt{\det(\Sigma)}} \] and \(\Sigma\) is a covariance matrix.
Now, we represent this model using canonical parameters. \[ \mathcal{N}_c (x \mid \xi, \Lambda) = c' \exp \left\{x^\top \xi - \frac{1}{2}x^\top \Lambda x \right\} \] where
- \(\Lambda = \Sigma^{-1}\) is a precision matrix
- \(\xi = \Sigma^{-1}\mu\) is a precision-weighted mean vector
- \(c' = \frac{\exp \left\{-\frac{1}{2}\xi^\top \Lambda^{-1} \xi \right\}}{(2\pi)^{\frac{D}{2}}\sqrt{\det(\Lambda^{-1})}}\).
This representation is called information form and can be converted to exponential family notation as follows: \[ \begin{align*} \mathcal{N}_c (x \mid \xi, \Lambda) &= (2\pi)^{-\frac{D}{2}} \exp \left\{\frac{1}{2}\log | \Lambda | -\frac{1}{2}\xi^\top \Lambda^{-1}\xi \right\} \exp \left\{-\frac{1}{2}x^\top \Lambda x + x^\top \xi \right\} \\\\ &= h(x)g(\eta)\exp \left\{-\frac{1}{2}x^\top \Lambda x + x^\top \xi \right\} \\\\ &= h(x)g(\eta)\exp \left \{-\frac{1}{2}(\sum_{i, j}x_i x_j \Lambda_{ij}) + x^\top \xi \right\} \\\\ &= h(x)g(\eta)\exp \left\{-\frac{1}{2}\operatorname{vec}(\Lambda)^\top \operatorname{vec}(xx^\top) + x^\top \xi \right\} \\\\ &= h(x)\exp\{\eta^\top \mathcal{T}(x) - A(\eta)\} \end{align*} \] where
- \(\mathcal{T}(x) = [x ; \operatorname{vec}(xx^\top)]\)
- \(\eta = [\xi ; -\frac{1}{2}\operatorname{vec}(\Lambda)] = [\Sigma^{-1}\mu ; -\frac{1}{2}\operatorname{vec}(\Sigma^{-1})]\)
- \(A(\eta) = -\log g(\eta) = -\frac{1}{2} \log | \Lambda | + \frac{1}{2}\xi^\top \Lambda^{-1} \xi \)
- \(h(x) = (2\pi)^{-\frac{D}{2}}\).
The moment parameters are given by: \[ m = [\mu ; \operatorname{vec}(\mu\mu^\top + \Sigma)]. \]
Note. For \(D \geq 2\) this form is non-minimal, because \(x_i x_j = x_j x_i\) makes the entries of \(\operatorname{vec}(xx^\top)\) repeat, so the natural parameter \(\eta\) is over-specified by \(D(D-1)/2\) redundant components. A minimal representation would keep each product \(x_i x_j\) with \(i \leq j\) once, and its natural parameter would have entries \(-\frac{1}{2}\Lambda_{ii}\) for the squares and \(-\Lambda_{ij}\) for \(i \lt j\). The off-diagonal entries carry the factor \(2\) because each collects the equal terms \(x_i x_j \Lambda_{ij}\) and \(x_j x_i \Lambda_{ji}\). However, in practice, the non-minimal representation is easier to plug into algorithms and stable for certain operations, while the minimal form is preferred for mathematical derivations.