参考自EM算法原理总结
    EM算法流程 - 图1

    EM算法的整体流程如下:

    输入:数据
    EM算法流程 - 图2%7D%2C%20x%5E%7B(2)%7D%2C%20%5Ccdots%2C%20x%5E%7B(m)%7D%5Cright%5C%7D#card=math&code=%5Cleft%5C%7Bx%5E%7B%281%29%7D%2C%20x%5E%7B%282%29%7D%2C%20%5Ccdots%2C%20x%5E%7B%28m%29%7D%5Cright%5C%7D&height=35&width=151)

    (1)先验给出模型的初始化参数
    EM算法流程 - 图3

    (2)for i from 1 to J:

    (a)E: 计算期望

    EM算法流程 - 图4%7D%5Cright)%3DP%5Cleft(z%5E%7B(i)%7D%20%7C%20x%5E%7B(i)%7D%2C%20%5Ctheta%5E%7Bj%7D%5Cright)%5Cright)%5C%5C%0A%26L%5Cleft(%5Ctheta%2C%20%5Ctheta%5E%7Bj%7D%5Cright)%3D%5Csum%7Bi%3D1%7D%5E%7Bm%7D%20%5Csum%7Bz%5E%7B(i)%7D%7D%20Q%7Bi%7D%5Cleft(z%5E%7B(i)%7D%5Cright)%20%5Clog%20P%5Cleft(x%5E%7B(i)%7D%2C%20z%5E%7B(i)%7D%20%3B%20%5Ctheta%5Cright)%0A%5Cend%7Baligned%7D%0A#card=math&code=%5Cbegin%7Baligned%7D%0A%26%5Cleft.Q%7Bi%7D%5Cleft%28z%5E%7B%28i%29%7D%5Cright%29%3DP%5Cleft%28z%5E%7B%28i%29%7D%20%7C%20x%5E%7B%28i%29%7D%2C%20%5Ctheta%5E%7Bj%7D%5Cright%29%5Cright%29%5C%5C%0A%26L%5Cleft%28%5Ctheta%2C%20%5Ctheta%5E%7Bj%7D%5Cright%29%3D%5Csum%7Bi%3D1%7D%5E%7Bm%7D%20%5Csum%7Bz%5E%7B%28i%29%7D%7D%20Q_%7Bi%7D%5Cleft%28z%5E%7B%28i%29%7D%5Cright%29%20%5Clog%20P%5Cleft%28x%5E%7B%28i%29%7D%2C%20z%5E%7B%28i%29%7D%20%3B%20%5Ctheta%5Cright%29%0A%5Cend%7Baligned%7D%0A&height=88&width=339)

    (b)M: 最大化
    EM算法流程 - 图5#card=math&code=L%5Cleft%28%5Ctheta%2C%20%5Ctheta%5E%7Bj%7D%5Cright%29&height=24&width=59)EM算法流程 - 图6

    EM算法流程 - 图7%0A#card=math&code=%5Ctheta%5E%7Bj%2B1%7D%3D%5Carg%20%5Cmax%20_%7B%5Ctheta%7D%20L%5Cleft%28%5Ctheta%2C%20%5Ctheta%5E%7Bj%7D%5Cright%29%0A&height=31&width=172)

    (c)如果已收敛,则算法结束,否则继续回到步骤(a)进行迭代

    输出:模型参数
    EM算法流程 - 图8