Ten Steps of EM Suffice for Mixtures of Two Gaussians
Constantinos Daskalakis, Christos Tzamos, Manolis Zampetakis
Introduction
The Expectation-Maximization (EM) algorithm [DLR77, Wu83, RW84] is one of the most widely used heuristics for maximizing likelihood in statistical models with latent variables. Consider a probability distribution sampling , where is a vector of observable random variables, a vector of non-observable random variables and a vector of parameters. Given independent samples of the observed random variables, the goal of maximum likelihood estimation is to select maximizing the log-likelihood of the samples, namely . Unfortunately, computing involves summing over all possible values of , which commonly results in a log-likelihood function that is non-convex with respect to and therefore hard to optimize. In this context, the EM algorithm proposes the following heuristic:
Start with an initial guess of the parameters.
(E-Step) For each sample , compute the posterior .
(M-Step) Set .
Intuitively, the E-step of the algorithm uses the current guess of the parameters, , to form beliefs, , about the state of the (non-observable) variables for each sample . Then the M-step uses the new beliefs about the state of for each sample to maximize with respect to a lower bound on . Indeed, by the concavity of the function, the objective function used in the M-step of the algorithm is a lower bound on the true log-likelihood for all values of , and it equals the true log-likelihood for . From these observations, it follows that the above alternating procedure improves the true log-likelihood until convergence.
Despite its wide use and practical significance, little is known about whether and under what conditions EM converges to the true maximum likelihood estimator. A few works establish local convergence of the algorithm to stationary points of the log-likelihood function [Wu83, Tse04, CH08], and even fewer local convergence to the MLE [RW84, BWY17]. Besides local convergence, it is also known that badly initialized EM may settle far from the MLE both in parameter and in likelihood distance [Wu83]. The lack of theoretical understanding of the convergence properties of EM is intimately related to the non-convex nature of the optimization it performs.
Our paper aims to illuminate why EM works well in practice and develop techniques for understanding its behavior. We do so by analyzing one of the most basic and natural, yet still challenging, statistical models EM may be applied to, namely balanced mixtures of two multi-dimensional Gaussians with equal and known covariance matrices. In particular, we study the convergence of EM when applied to the following family of parametrized density functions:
where is a known covariance matrix, are unknown (vector) parameters, and represents the Gaussian density with mean and covariance matrix , i.e.
Our main contribution is to provide global convergence guarantees for EM applied to the above family of distributions. We establish our result for both the “population version” of the algorithm, and the finite-sample version, as described below.
To elucidate the optimization features of the algorithm and avoid analytical distractions arising due to sampling error, it has been standard practice in the literature of theoretical analyses of EM to consider the “population version” of the algorithm, where the EM iterations are performed assuming access to infinitely many samples from a distribution as above. With infinitely many samples, we can identify the mean, , of , and re-parametrize the density around the mean as follows:
We first study the convergence of EM when we perform iterations with respect to the parameter of in (1.1). Starting with an initial guess for the unknown mean vector , the -th iteration of EM amounts to the following update:
where we have compacted both the E- and M-step of EM into one update.
The intuition behind the EM update formula is as follows. First, we take expectations with respect to because we are studying the population version of EM, hence we assume access to infinitely many samples from . For each sample , the ratio is our belief, at step , that was sampled from the first Gaussian component of , namely the one for which our current estimate of its mean vector is . (The complementary probability is our present belief that was sampled from the other Gaussian component.) Given these beliefs for all vectors , the update (1.2) is the result of the M-step of EM. Intuitively, our next guess for the mean vector of the first Gaussian component is a weighted combination over all samples where the weight of every is our belief that it came from the first Gaussian component.
Our main result for population-EM is the following:
Whenever the initial guess is not equidistant to and , EM converges geometrically to either or , with convergence rate that improves as . We provide a simple, closed form expression of the convergence rate as a function of and . If the initial guess is equidistant to and , EM converges to the unstable fixed point .
A formal statement is provided as Theorem 2 in Section 4. We start with the proof of the single-dimensional version, presented as Theorem 1 in Section 3. As a simple illustration of our result, we show in Section 5 that, in one dimension, when our original guess and the signal-to-noise ratio , steps of the EM algorithm result in error.
Despite the simplicity of the case we consider, no global convergence results were known prior to our work, even for the population EM. [BWY17] studied the same setting proving only local convergence, i.e. convergence only when the initial guess is close to the true parameters. They argue that the population EM update is contracting close to the true parameters. Unfortunately, the EM update is non-contracting outside a small neighborhood of the true parameters so this argument cannot be used for a global convergence guarantee.
In this work, we study the problem under arbitrary starting points and completely characterize the fixed points of EM. We show that other than a measure-zero subset of the space (namely points that are equidistant from the centers of the two Gaussians), any initialization of the EM algorithm converges to the true centers of the Gaussians, providing explicit bounds for the convergence rate. To achieve this, we follow an orthogonal approach to [BWY17]: Instead of trying to directly compute the number of steps required to reach convergence for a specific instance of the problem, we study the sensitivity of the EM iteration as the instance varies. The intuition is that if the EM update is sensitive to updating the instance, then changing the instance should also attract the update towards the changing instance; see Figure 1. We can use this, in turn, to argue that keeping the instance fixed, one EM update makes progress towards the true parameters. In particular, we gain a handle on the convergence rate of EM on all instances at once. This is quantified by Eq. (3.2).
Analysis of Finite-Sample EM for Mixtures of Two Gaussians.
Bootstrapping EM for Faster Convergence.
We note that, in multiple dimensions, care must be taken in initializing the EM algorithm, even in the infinite sample regime, as the convergence guarantee depends on the angle between the current iterate and the true mean vector. While a randomly chosen unit vector will have projection of in the direction of , we argue that we can boostrap EM to turn this projection larger than a constant. This allows us to work with similar convergence rates as in the single-dimensional case, namely only SNR (and not dimension) dependent. Our initialization procedure is described in Section 6.3.
EM can be boostrapped so that the number of iterations required to approximate and to within Mahalanobis distance depends logarithmically in the dimension.
Related Work on Learning Mixtures of Gaussians.
We have already outlined the literature on the Expectation-Maximization algorithm. Several results study its local convergence properties and there are known cases where badly initialized EM fails to converge. See above.
There is also a large body of literature on learning mixtures of Gaussians. A long line of work initiated by Dasgupta [Das99, AK01, VW04, AM05, KSV05, DS07, CR08, BV08, CDV09] provides rigorous guarantees on recovering the parameters of Gaussians in a mixture under separability assumptions, while later work [KMV10, MV10, BS10] has established guarantees under minimal information theoretic assumptions. More recent work [HP15] provides tight bounds on the number of samples necessary to recover the parameters of the Gaussians as well as improved algorithms, while another strand of the literature studies proper learning with improved running times and sample sizes [SOAJ14, DK14]. Finally, there has been work on methods exploiting general position assumptions or performing smoothed analysis [HK13, GHK15].
In practice, the most common algorithm for learning mixtures of Gaussians is the Expectation-Maximization algorithm, with the practical experience that it performs well in a broad range of scenarios despite the lack of theoretical guarantees. Recently, Balakrishnan, Wainwright and Yu [BWY17] studied the convergence of EM in the case of an equal-weight mixture of two Gaussians with the same and known covariance matrix, showing local convergence guarantees. In particular, they show that when EM is initialized close to the actual parameters, then it converges. In this work, we revisit the same setting considered by [BWY17] but establish global convergence guarantees. We show that, for any initialization of the parameters, the EM algorithm converges geometrically to the true parameters. We also provide a simple and explicit formula for the rate of convergence.
Concurrent and independent work by Xu, Hsu and Maleki [XHM16] has also provided global and geometric convergence guarantees for the same setting, as well as a slightly more general setting where the mean of the mixture is unknown, but they do not provide explicit convergence rates. They also do not provide an analysis of the finite-sample regime.
Preliminary Observations
In this section we illustrate some simple properties of the EM update (1.2) and simplify the formula. First, it is easy to see that plugging in the values into results into
In particular, for all , these values are certainly fixed points of the EM iteration. Next, we rewrite as follows:
It is easy to observe that by symmetry this simplifies to
Simplifying common terms in the density functions , we get that
We thus get the following expression for the EM iteration
Single-dimensional Convergence
In the single dimensional case the EM algorithm takes the following form according to (2.2).
Observe that the function is increasing with respect to . Indeed the partial derivative of with respect to is
which is strictly greater than zero since the function is strictly positive.
We will show next that the fixed points we identified at (2.1) are the only fixed points of . When initialized with (resp. ), the EM algorithm converges to (resp. to ). The point is an unstable fixed point.
In the single dimensional case, when , the parameters satisfy
Moreover is a decreasing function of .
For simplicity we will use for , for and we will assume that .
By a simple change of variables we can see that
The main idea is to use the Mean Value Theorem with respect to the second coordinate of the function on the interval .
But we know that and and therefore we get
where we have used the fact that which is comes from the fact that is increasing with respect to and that .
The only thing that remains to complete our proof is to prove a lower bound of the partial derivative of with respect to .
The first term is non-negative, Lemma 1. The second term is at least , Lemma 2 and the theorem follows. ∎
But now we can see that since is an even function and since for any we have then
Multi-dimensional Convergence
In the multidimensional case, the EM algorithm takes the form of (2.2). In this case, we will quantify our approximation guarantees using the Mahalanobis distance between vectors with respect to matrix , defined as follows:
We will show that the fixed points identified in (2.1) are the only fixed points of . When initialized with such that (resp. ), the EM algorithm converges to (resp. to ). The algorithm converges to when initialized with . In particular,
Whenever , i.e. the initial guess is closer to than , the estimates of the EM algorithm satisfy
Moreover, is a decreasing function of . The symmetric things hold when . When the initial guess is equidistant to and , then for all .
For simplicity we will use for , for .
By applying the following change of variables and we may assume that where is the identity matrix. Therefore the iteration of EM becomes
Since the Normal distribution is rotation invariant we can equivalently write:
We now consider different cases for to further simplify Equation (4.2).
Let as defined before and using Lemma 2 we get that
We can now bound the distance of from :
We now have to prove that this convergence rate decreases as the iterations increase. This is implied by the following lemmas which show that
If then and .
The analysis above implies that can be written in the form , where and . It is easy to see that the first inequality holds since . For the second, we write as:
where we used the fact that which follows by the bounds on and . ∎
If then .
We have that , where and . We also have so the lemma follows. ∎
Finally substituting back in the basis that we started before changing coordinates to make the covariance matrix identity we get the result as stated at the theorem. ∎
An Illustration of the Speed of Convergence
Using our results in the previous sections we can calculate explicit speeds of convergence of EM to its fixed points. In this section, we present some results with this flavor. For simplicity, we start with single dimensional case, and discuss the multi-dimensional case in the end of this section.
Let us consider a mixture of two single-dimensional Gaussians whose signal-to-noise ratio is equal to . There is nothing special about the value of , except that it is a difficult case to consider since the Gaussian components are not separated, as shown in Figure 3.
When the SNR is larger, the numbers presented below still hold and in reality the convergence is even faster. When the SNR is even smaller than one, the numbers change, but gracefully, and they can be calculated in a similar fashion.
We will also assume a completely agnostic initialization of EM, setting .In the multi-dimensional setting, this would corrrespond to a very large magnitude chosen in a random direction. To analyze the speed of convergence of EM to its fixed point , we first make the observation that in one step we already get to . To see this we can plug into equation (3.1) to get:
which equals the mean of the Folded Normal Distribution. A well-known bound for this mean is . Therefore the distance from the true mean after one step is .
Now, using Theorem 1, we conclude that in all subsequent steps the distance to shrinks by a factor of at least . This means that, if we want to estimate to within additive error , then we need to run EM for at most additional steps. Accounting for the first step, iterations of the EM algorithm in total suffice to get to within error , even when our initial guess of the mean is infinitely away from the true value!
The analysis given above for , generalizes to arbitrary s, at the cost of a factor of in the number of iterations. It also generalizes to obtain an arbitrary approximation , at a cost of a factor of . In multiple dimensions, we could run EM from a random initialization. The number of iterations for an approximation of in Mahalanobis distance would depend on the angle of the initial iterate with . Under a random initialization, the cosine of that angle is expected to be , resulting in a total number of iterations. We show that we can boostrap EM to obtain a better initialization, starting from a random one, improving the angle to , after iterations. With a constant angle, EM takes iterations to give error, as in the single dimension, overall improving exponentially the dependence on . We describe our bootstrapping operation in the context of our analysis of the finite sample EM in Section 6.3.
Sample Based Model
The main goal of this section is to prove convergence guarantees for the EM algorithm, when we have a finite sample. Similarly to the Section 4 we willquantify our approximation guarantees using the Mahalanobis distance between two vectors with respect to matrix , which we remind is defined as follows:
Also for the simplicity of the notation, it is useful to define the Mahalanobis inner product between two vectors with respect to matric as follows:
Towards our goal, we encounter two challenges.
The first is that we cannot assume that we exactly know the mean of the mixture distribution . Our only access to this mean is via samples. We therefore use samples to estimate it. Then, we translate the origin to our estimate, and write the EM iteration for finding the mean of one of the two mixture components with respect to this origin. Given the error incurred in the approximation of , we propose to stabilize the sample-based EM iteration by including in the sample for each sampled point its symmetric point . This is the sample based version that we analyze, although our analysis goes through without this stabilization.
We use to refer to the error in our estimation .
Combining the above steps all together we get our main theorem for this section.
We start now proving the lemmas for each of the steps described above.
We start by making the transformation to the space, so that the covariance matrix is the identity . Finally we will take back this transformation and the Euclidean norm becomes the corresponding Mahalanobis.
We will get an estimate of the mean by drawing samples from the mixture and working in each axis direction separately. We will compute the estimate in axis direction as the average of the first and third quartile of the empirical distribution given by the samples. It suffices to show that with high probability every quartile is at most away from the true quartile of the distribution .
Let be the mixture of Gaussian distributions obtained by centering around .
The cumulative distribution of is given by . By the DKW inequality [DL12] with samples we have that the empirical distribution satisfies:
In particular, for such that , with high probability . Moreover, for such that , we have that by the mean value theorem.
Since for , , this implies that and thus . But when which shows that . Similarly, this holds for the 3rd quartile as well and thus the same bound holds for the mean as well of the two quartiles with probability . Setting , we get that the bound is violated with probability . Taking a union bound for all axis directions, we get that for all , with constant probability. This implies that with constant probability. By using a factor of more samples it is easy to see that the error probability reduces to . ∎
2 Sample Based EM Iteration
Using the estimation of the center that we found in the previous section, we translate all our data and parameters so that . After this centering, the parameters , become , and the covariance matrix remains the same.
3 Initialization of EM
We rewrite the sample based EM iteration is the following form
where is the empirical covariance matrix of the mixture . Now the intuition suggests that the direction of the maximum eigenvector of the matrix is a direction that is spanned by , and hence a direction with small angle to the direction of . Also observe that this approximate EM iteration is actually an iteration of the power method for the matrix ! Because of the efficiency of the power method, we expect that after a few steps this iteration will find a direction such that the inner product is large enough. This direction is a good initialization for the EM algorithm as we will see in the next section. We now formaly demonstrate the intuition we described for the approximate EM update.
We start by bounding the error we introduce by replacing the function with its linear approximation. It is very easy to see that . Now by Taylor expansion of around we get that
At this point the calculations become much easier if we assume that we have already done the mapping and when we are done we will take the inverse mapping and get the result in Mahalanobis distance. Equation (6.4) suggests that it suffices to analyze the convergence of the power method given by the following equation.
where is the empirical covariance matrix of the mixture . Before analyzing (6.5) lets see what happens if instead of the empirical covariance we had the actual covariance of the mixture distribution . Then the iteration would be . The covariance matrix of the mixture is
Therefore the principal eigenvector of is with eigenvalue , where . All the other eigenvectors have eigenvalue and therefore the ratio of the largest to the lowest eigenvalue is .
To get the corresponding properties of we observe that each can be written as
where is distributed as and is a Rademacher indicator variable that shows whether is coming from the distribution or . We notice that and are independent. We can now rewrite in terms of and .
We describe now a sketch of the proof of Lemma 6, using the following Lemma 25 from [DKT15].
For all , ,
For all , .
Now we consider the quantity , where is the unit th vector. This is equivalent with having where is drawn from . So we have that
Now by doing a union bound over all we get that
For , it is easy to observe that in , are independent from and so the product is a sample from standard multinormal distribution . Therefore we can substitute with just . Now using exactly the same analysis as in Lemma 7 we can prove the following lemma.
Now we calculate the variance of the samples in the direction of . We have
The principal eigenvector of has to satisfy
Now using an such that we have that the above implies . This proves the following Proposition that we use in the analysis of the initialization step.
The last thing we need to prove to complete the analysis of the initialization is the gap between the first and the second eigenvalue of . We want to use this gap for the analysis of the convergence rate of the power method iteration that takes place in the first steps. Given Proposition refprop:principalVectorSp, we have that any direction except from the principal one, has with high probability. Let be the eigenvector that corresponds to the second maximum eigenvalue of . Let , using Lemmas 6, 8, 7 and (6.7) we have that
On the other hand based on the fact that we conclude that
Using also the hypothesis that we get that
It is well known and easy to prove that if we choose a random vector uniformly from the half unit sphere, defined by , then we will have that with high probability.
But is and therefore
Finally since is and also we only need to set polynomially with respect to and we will get that after the first iterations it holds that
for some . Which implies that
This proves the following lemma and completes the proof of the initialization.
4 Finite-Sample EM Analysis
We initialize EM at , where is the point from Lemma 9, for some large constant .It is easy to find such constant by getting a small number of samples and keeping the one that has maximum magnitude. With this initialization, we run EM for steps using samples at each step, where for ease of notation we have set .
To study our sample-based EM iteration (6.1) we will relate its progress to an appropriate population EM iteration. Note that this iteration differs from the population EM iteration that we discussed in Section 2 and analyzed in Section 4. The reason is that we have incurred an error in the estimation of the mean of the distribution in Section 6.1. With respect to our estimated mean centering, the true means of the two Gaussian components are , rather than and . Another source of discrepancy comes from the fact that we included for each point in our sample its symmetric point . This implies that each is coming with probability from the mixture and with probability from the mixture . Given this, using again the same operations as in Section 2, we have that the corresponding population iteration, denoted by , is
Our proof follows two steps illustrated in Figures 2 and LABEL:fig:graph3:
Step 1: First, we relate the population EM iteration defined by (6.8) to the vanilla population EM iteration defined by (2.2);
Step 2: Then, we related the population EM iteration defined by (6.8) to the sample-based iteration.
To analyze the convergence of (6.8), we use Theorem 2 for every component of the mixture. More precisely, let and be
We are ready now to bound the convergence of
We can use the analysis of Section 4 to see that . Therefore we also know that the population iteration satisfies:
where for simplicity we let . Now we have . Also is larger than and because of Lemma 9 with high probability, where . Therefore
and since we have that
Also we have that and therefore (6.11) becomes
Step 2:
Now we define , and we have
where is distributed as and . For simplicity we refer to as . Our goal is to bound the following probability
to do so we use the general large deviation technique. Because of symmetry of , we have that the above probability is equal twice the probability
Now we use the following Lemma 2.1 of [Wai15].
where are standard multivariate Gaussian, and independent.
Now for the second term of (6.17) we notice that as we present in Section 3
which imlies using the mean value theorem that
Putting all together to (6.17) we have that
As before we define , and we have
where is distributed as , is distributed as and . For simplicity we refer to as . Our goal is to bound the following probability
to do so we use the general large deviation technique. Using the symmetry of and we have that the above probability is equal twice the
Using the fact that because of the initialization of EM and by assumption and also let we have to bound the quantity
Now using a simple Taylor expansion used in the proof of the Hoeffding bound we get that the first term of (6.22) is less than or equal to
Now for the second term of (6.22) we have that
Putting all together to (6.22) we have that
For any we follow the same analysis as for the bound (6.23) but because of the definition of the basis we have that and therefore
Finally if we combine (6.18), (6.23) and (6.24) using the observation that we get that
Proof of Theorem 3:
Acknowledgements
We thank Sham Kakade for suggesting the problem to us, and for initial discussions. The authors were supported by NSF Awards CCF-0953960 (CAREER), CCF-1551875, CCF-1617730, and CCF-1650733, ONR Grant N00014-12-1-0999, and a Microsoft Faculty Fellowship.