Exponential Family

The exponential family distributions are very important in graphical models and Bayesian learning. They have nice properties, like conjugacy and finite sufficient statistics, which enable the convenience and efficiency of the inference and learning process. Yet, I only almost know the details of exponential family distribution. The minor gap between “almost know” and “know” prevents me from understanding it completely. Here I try to close the gap.


The canonical/natural form of exponential family distribution is of the form

where $\theta$ is the natural parameter, $\phi(x)$ is sufficient statistics, $Z(\theta)$ is the partition function, $A(\theta)$ is the log partition function. Let’s write the univariate Gaussian distribution in exponential family form

Therefore, it is easy to tell that

There is one beautiful property of the log partition function $\nabla_{\theta}A(\theta) = \mathbb{E}_{p(x)}[\phi(x)]$.

MLE Estimation

Given dataset $\mathcal{D}={x_1, x_2,\cdots,x_N}$, the data likelihood of an exponential family model has the form

We see that the sufficient statistics are $N$ and $\sum_{i=1}^N \phi(x_i)$. The loglikelihood of the data $\log p(\mathcal{D}|\theta) = \theta^T \phi(\mathcal{D}) - N A(\theta)$ is concave since $-A(\theta)$ is concave in $\theta$, and $\theta^T \phi(\mathcal{D})$ is linear in $\theta$. To compute MLE for the model, we can compute the derivative of the log-likelihood:

Setting this gradient to zero, we see that the empirical average of the sufficient statistics must equal the model’s theoretical expected sufficient statistics, i.e. $\hat{\theta}$ must satiesfy

We need to solve this equation for specific type of distribution, which I will give some examples.

MLE for Gaussian distribution

For Gaussian distribution, following above, the MLE corresponds to solve

Solving this, we have

EM for Gaussian Mixture

For Gaussian mixture, we can use EM to perform MLE. But first, we should identify the MLE under complete data situation. We know that $p(x|\theta) = \sum_k p(z_k, x) = \sum_k p(z^k=1|\pi) p(x|z^k=1,\mu,\Sigma) = \sum_k \pi_k\mathcal{N}(x|\mu_k, \Sigma_k))$. If we assume that all variables are observed, we can learn the parameters simply by using MLE. The data likelihood is

Obviously, the sufficient statistics and natural parameter can be identified:

Here we are also able to compute the expected sufficient statistics of the random variable $X$ and $Z$

Using the MLE rule, given the dataset $\mathcal{D}={x_1, x_2,\cdots,x_N}$, we need to set the $\mathbb{E}[\phi(X)] = \frac{1}{N}\sum_{i=1}^N\phi(x_i)$. This leads to

Note that the derivation is different from P351 in Murphy’s book, where one has to enforce the constraints to derive the maximization of $\pi$. Here since we use the MLE property in exponential family, it simplifies the derivation a lot. The results are exactly the same. Now that we have identified the rule for converting the sufficient statistics to the MLE of the parameters, we can now use the EM. In the E-step, we complete the data by computing the posterior distribution of $z$ under current parameter setting $p(z_i^k=1|x_i,\theta^t)$

In the M-step, we compute optimize the expected complete data loglikelihood, i.e. MLE. This corresponds to take the expectation of the sufficient statistics over $p(z_i^k=1|x_i,\theta^t)$. Then we follow the MLE estimation using the expected sufficient statistics, i.e.

Stepwise EM for Gaussian Mixture

The reason why I tried to figure out the derivation of Gaussian mixture using sufficient statistics, instead of the one presented in the book, is that using sufficient statistics will lead to more general optimization method, such as stepwise EM and stochastic variational inference. Stepwise EM is computed as follows

Since we are able to convert sufficient statistics into the MLE of the parameters as above, we only need to update the sufficient statistics $\mu$. Therefore, the Stepwise EM for Gaussian Mixture is as follows

For Stepwise EM with minibatch of size $m$, the algorithm is as follows: