




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





In the previous set of notes, we talked about the EM algorithm as applied to fitting a mixture of Gaussians. In this set of notes, we give a broader view of the EM algorithm, and show how it can be applied to a large family of estimation problems with latent variables. We begin our discussion with a very useful result called Jensen’s inequality
Let f be a function whose domain is the set of real numbers. Recall that f is a convex function if f ′′(x) ≥ 0 (for all x ∈ R). In the case of f taking vector-valued inputs, this is generalized to the condition that its hessian H is positive semi-definite (H ≥ 0). If f ′′(x) > 0 for all x, then we say f is strictly convex (in the vector-valued case, the corresponding statement is that H must be strictly positive semi-definite, written H > 0). Jensen’s inequality can then be stated as follows:
Theorem. Let f be a convex function, and let X be a random variable. Then: E[f (X)] ≥ f (EX).
Moreover, if f is strictly convex, then E[f (X)] = f (EX) holds true if and only if X = E[X] with probability 1 (i.e., if X is a constant).
Recall our convention of occasionally dropping the parentheses when writ- ing expectations, so in the theorem above, f (EX) = f (E[X]). For an interpretation of the theorem, consider the figure below.
a E[X] (^) b
f(a)
f(b) f(EX)
E[f(X)]
f
Here, f is a convex function shown by the solid line. Also, X is a random variable that has a 0.5 chance of taking the value a, and a 0.5 chance of taking the value b (indicated on the x-axis). Thus, the expected value of X is given by the midpoint between a and b. We also see the values f (a), f (b) and f (E[X]) indicated on the y-axis. Moreover, the value E[f (X)] is now the midpoint on the y-axis between f (a) and f (b). From our example, we see that because f is convex, it must be the case that E[f (X)] ≥ f (EX). Incidentally, quite a lot of people have trouble remembering which way the inequality goes, and remembering a picture like this is a good way to quickly figure out the answer. Remark. Recall that f is [strictly] concave if and only if −f is [strictly] convex (i.e., f ′′(x) ≤ 0 or H ≤ 0). Jensen’s inequality also holds for concave functions f , but with the direction of all the inequalities reversed (E[f (X)] ≤ f (EX), etc.).
2 The EM algorithm
Suppose we have an estimation problem in which we have a training set {x(1),... , x(m)} consisting of m independent examples. We wish to fit the parameters of a model p(x, z) to the data, where the likelihood is given by
`(θ) =
∑^ m
i=
log p(x; θ)
∑^ m
i=
log
z
p(x, z; θ).
natural to try to make the lower-bound tight at that value of θ. I.e., we’ll make the inequality above hold with equality at our particular value of θ. (We’ll see later how this enables us to prove that `(θ) increases monotonically with successsive iterations of EM.) To make the bound tight for a particular value of θ, we need for the step involving Jensen’s inequality in our derivation above to hold with equality. For this to be true, we know it is sufficient that that the expectation be taken over a “constant”-valued random variable. I.e., we require that
p(x(i), z(i); θ) Qi(z(i))
= c
for some constant c that does not depend on z(i). This is easily accomplished by choosing Qi(z(i)) ∝ p(x(i), z(i); θ).
Actually, since we know
z Qi(z
(i)) = 1 (because it is a distribution), this
further tells us that
Qi(z(i)) =
p(x(i), z(i); θ) ∑ z p(x (i), z; θ)
p(x(i), z(i); θ) p(x(i); θ) = p(z(i)|x(i); θ)
Thus, we simply set the Qi’s to be the posterior distribution of the z(i)’s given x(i)^ and the setting of the parameters θ. Now, for this choice of the Qi’s, Equation (3) gives a lower-bound on the loglikelihood ` that we’re trying to maximize. This is the E-step. In the M-step of the algorithm, we then maximize our formula in Equation (3) with respect to the parameters to obtain a new setting of the θ’s. Repeatedly carrying out these two steps gives us the EM algorithm, which is as follows:
Repeat until convergence {
(E-step) For each i, set
Qi(z(i)) := p(z(i)|x(i); θ).
(M-step) Set
θ := arg max θ
i
z(i)
Qi(z(i)) log
p(x(i), z(i); θ) Qi(z(i))
How we we know if this algorithm will converge? Well, suppose θ(t) and θ(t+1)^ are the parameters from two successive iterations of EM. We will now prove that (θ(t)) ≤(θ(t+1)), which shows EM always monotonically improves the log-likelihood. The key to showing this result lies in our choice of the Qi’s. Specifically, on the iteration of EM in which the parameters had started out as θ(t), we would have chosen Q( it )(z(i)) := p(z(i)|x(i); θ(t)). We saw earlier that this choice ensures that Jensen’s inequality, as applied to get Equation (3), holds with equality, and hence
`(θ(t)) =
i
z(i)
Q( it )(z(i)) log
p(x(i), z(i); θ(t)) Q( i t)(z(i))
The parameters θ(t+1)^ are then obtained by maximizing the right hand side of the equation above. Thus,
`(θ(t+1)) ≥
i
z(i)
Q( i t)(z(i)) log
p(x(i), z(i); θ(t+1)) Q( it )(z(i))
i
z(i)
Q( i t)(z(i)) log
p(x(i), z(i); θ(t)) Q( it )(z(i))
= `(θ(t)) (6)
This first inequality comes from the fact that
`(θ) ≥
i
z(i)
Qi(z(i)) log
p(x(i), z(i); θ) Qi(z(i))
holds for any values of Qi and θ, and in particular holds for Qi = Q( it ), θ = θ(t+1). To get Equation (5), we used the fact that θ(t+1)^ is chosen explicitly to be
arg max θ
i
z(i)
Qi(z(i)) log
p(x(i), z(i); θ) Qi(z(i))
and thus this formula evaluated at θ(t+1)^ must be equal to or larger than the same formula evaluated at θ(t). Finally, the step used to get (6) was shown
earlier, and follows from Q( it )having been chosen to make Jensen’s inequality hold with equality at θ(t).
Lets maximize this with respect to μl. If we take the derivative with respect to μl, we find
∇μl
∑^ m
i=
∑^ k
j=
w( ji )log
1 (2π)n/^2 |Σj |^1 /^2 exp^
−^12 (x(i)^ − μj )T^ Σ− j 1 (x(i)^ − μj )
· φj
w j(i)
= −∇μl
∑^ m
i=
∑^ k
j=
w( ji)
(x(i)^ − μj )T^ Σ− j 1 (x(i)^ − μj )
∑^ m
i=
w l( i)∇μl 2 μTl Σ− l 1 x(i)^ − μTl Σ− l 1 μl
∑^ m
i=
w (i) l
Σ− l 1 x(i)^ − Σ− l 1 μl
Setting this to zero and solving for μl therefore yields the update rule
μl :=
∑m i=1 w
(i) l x
(i) ∑m i=1 w
(i) l
which was what we had in the previous set of notes. Lets do one more example, and derive the M-step update for the param- eters φj. Grouping together only the terms that depend on φj , we find that we need to maximize ∑m
i=
∑^ k
j=
w( ji )log φj.
However, there is an additional constraint that the φj ’s sum to 1, since they represent the probabilities φj = p(z(i)^ = j; φ). To deal with the constraint
that
∑k j=1 φj^ = 1, we construct the Lagrangian
L(φ) =
∑^ m
i=
∑^ k
j=
w( ji )log φj + β(
∑^ k
j=
φj − 1),
where β is the Lagrange multiplier.^2 Taking derivatives, we find
∂ ∂φj
L(φ) =
∑^ m
i=
w( ji) φj
(^2) We don’t need to worry about the constraint that φj ≥ 0, because as we’ll shortly see,
the solution we’ll find from this derivation will automatically satisfy that anyway.
Setting this to zero and solving, we get
φj =
∑m i=1 w
(i) j −β
I.e., φj ∝
∑m i=1 w
(i) j.^ Using the constraint that^
j φj^ = 1, we easily find that −β =
∑m i=
∑k j=1 w
(i) j =^
∑m i=1 1 =^ m. (This used the fact that^ w
(i) j = Qi(z(i)^ = j), and since probabilities sum to 1,
j w
(i) j = 1.)^ We therefore have our M-step updates for the parameters φj :
φj :=
m
∑^ m
i=
w (i) j.
The derivation for the M-step updates to Σj are also entirely straightfor- ward.