EM Algorithm -- parameter estimation with missing data

🎨EM Algorithm – parameter estimation with missing data

0x01. Introduction

Expectation Maximization is a technique used to estimate probability densities (概率密度函数,pdf)under missing data

  • Parametric:
    provide a parametrized class of pdf, e.g. Gaussians: p(x)=f(x,mean,std), reflect prior knowledge
    estimation: to find the parameters which best fit the data(拟合数据), measure with Maximum Likelihood
  • Non-parametric
    pdf is modeled explicitly through the samples.
    e.g. KNN

0x02. Missing data problem

  • intrinsically inaccessible, e.g:
    mixture models: which cluster does a data point belong to?
    在这里插入图片描述
  • data is lost

0x03. 预备知识

1. 极大似然估计

(1)举例说明:经典问题——学生身高问题

我们需要调查我们学校的男生和女生的身高分布。 假设你在校园里随便找了100个男生和100个女生。他们共200个人。将他们按照性别划分为两组,然后先统计抽样得到的100个男生的身高。假设他们的身高是服从正态分布的。但是这个分布的均值 μ μ μ 和方差 σ 2 \sigma^2 σ2 我们不知道,这两个参数就是我们要估计的。记作 θ = [ μ , σ ] T θ=[μ,σ]^T θ=[μ,σ]T
  
问题数学化. 设样本集 X = x 1 , x 2 , … , x N X = x_1,x_2,…,x_N X=x1,x2,,xN,其中 N = 100 N=100 N=100 p ( x i ∣ θ ) p(x_i|θ) p(xiθ)为概率密度函数,表示抽到男生身高为 x i x_i xi的概率。由于100个样本之间独立同分布,所以我同时抽到这100个男生的概率就是他们各自概率的乘积,也就是样本集 X中各个样本的联合概率,用下式表示:
在这里插入图片描述
这个概率反映了,在概率密度函数的参数是 θ θ θ 时,得到 X X X 这组样本的概率。 我们需要找到一个参数 θ θ θ,使得抽到 X X X 这组样本的概率最大,也就是说需要其对应的似然函数 L ( θ ) L(θ) L(θ) 最大。满足条件的 θ θ θ 叫做 θ θ θ 的最大似然估计量,记为
θ ′ = a r g m a x L ( θ ) θ' =argmaxL(θ) θ=argmaxL(θ)
求最大似然函数估计值的一般步骤

  • 首先,写出似然函数:
    在这里插入图片描述

  • 然后,对似然函数取对数:
    在这里插入图片描述

  • 接着,对上式按 θ θ θ 求导,令导数为0,得到似然方程;

  • 最后,求解似然方程,得到的参数 θ θ θ 即为所求。

2. 琴生不等式

设 f是定义域为实数的函数,如果f(x)的二次导数恒大于等于0,那么f是凸函数。

Jensen不等式表述如下:如果 f f f 是凸函数, X X X 是随机变量,那么: E [ f ( X ) ] ≥ f ( E [ X ] ) E[f(X)]≥f(E[X]) E[f(X)]f(E[X])。当且仅当 X X X 是常量时,上式取等号。

例如,图2中,实线 f f f 是凸函数, X X X 是随机变量,有0.5的概率是a,有0.5的概率是 b。X的期望值就是 a和b的中值了,图中可以看到 E [ f ( X ) ] ≥ f ( E [ X ] ) E[f(X)]≥f(E[X]) E[f(X)]f(E[X]) 成立。
  在这里插入图片描述

0x04.EM算法详解

1.问题描述

我们目前有100个男生和100个女生的身高,共200个数据,但是我们不知道这200个数据中哪个是男生的身高,哪个是女生的身高。
假设男生、女生的身高分别服从正态分布,则每个样本是从哪个分布抽取的,我们目前是不知道的。这个时候,对于每一个样本,就有两个方面需要猜测或者估计: 这个身高数据是来自于男生还是来自于女生?男生、女生身高的正态分布的参数分别是多少?EM算法要解决的问题正是这两个问题。
还记得上面的这个图吗:
在这里插入图片描述
我们现在就是不知道每个点都属于哪个分布。

2. EM算法推导

样本集 X = x 1 , x 2 , … , x m X = { x_1,x_2,…,x_m} X=x1,x2,,xm,包含 m个独立的样本;每个样本 x i x_i xi对应的类别 z i z_i zi是未知的(即上文中每个样本属于哪个分布,男生\女生 是未知的);我们需要估计参数 θ θ θ,即需要找到适合的 θ θ θ z z z L ( θ ) L(θ) L(θ) 最大。极大似然估计中的似然函数取对数所得 l o g L ( θ ) logL(θ) logL(θ),可以得到如下式:
L ( X ∣ θ ) = ∏ i p ( x ( i ) ∣ θ ) L(X|\theta)= \prod_i p(x^{(i)}|\theta) L(Xθ)=ip(x(i)θ),取对数后:
l o g L ( X ∣ θ ) = ∑ i l o g p ( x ( i ) ∣ θ ) logL(X|\theta) = \sum _i logp(x^{(i)}|\theta) logL(Xθ)=ilogp(x(i)θ)
在这里插入图片描述
其中,(1)式是根据全概率公式计算得来,(2)式是由(1)式分子分母同乘一个数得到,(3)式是由(2)式根据Jensen不等式得到。
这里简单介绍一下(2)式到(3)式的转换过程:由于 ∑ Q i ( z ( i ) ) [ p ( x ( i ) , z ( i ) ; θ ) Q i ( z ( i ) ) ] ∑Qi(z(i))[\frac{p(x(i),z(i);θ)}{Qi(z(i))}] Qi(z(i))[Qi(z(i))p(x(i),z(i);θ)] p ( x ( i ) , z ( i ) ; θ ) Q i ( z ( i ) ) \frac{p(x(i),z(i);θ)}{Qi(z(i))} Qi(z(i))p(x(i),z(i);θ)的期望,且 log(x)为凹函数,根据Jensen不等式,当 f是凹函数时,E[f(X)]≤f(E[X])成立,可由(2)式得到(3)式。

上述过程可以看作是对 l o g L ( θ ) logL(θ) logL(θ) 求了下界。对于 Q i ( z ( i ) ) Q_i(z^{(i)}) Qi(z(i)) 的选择,有多种可能,那么哪种更好呢?假设 θ θ θ 已经给定,那么 logL(θ)的值就取决于 Qi(z(i))和 p(x(i),z(i))]了。我们可以通过调整这两个概率使下界不断上升,以逼近 logL(θ)的真实值,那么什么时候算是调整好了呢?当不等式变成等式时,说明我们调整后的概率能够等价于 logL(θ)了。按照这个思路,我们要找到等式成立的条件。根据Jensen不等式,要想让等式成立,需要让随机变量变成常数值,这里得到:
p ( x ( i ) , z ( i ) ; θ ) Q i ( z ( i ) ) = c \frac{p(x(i),z(i);θ)}{Qi(z(i))}=c Qi(z(i))p(x(i),z(i);θ)=c
对此式做进一步推导:由于 ∑ z ( i ) Q i ( z ( i ) ) = 1 ∑_{z(i)}Qi(z^{(i)})=1 z(i)Qi(z(i))=1,则有 ∑ z ( i ) p ( x ( i ) , z ( i ) ; θ ) = c ∑_{z(i)}p(x^{(i)},z^{(i)};θ)=c z(i)p(x(i),z(i);θ)=c因此得到下式:
z是隐型变量(男\女),x是观测的值。
z是隐型变量(男\女),x是观测的值。

至此,我们推出了: 在固定参数θ后, Q i ( z ( i ) ) Q_i(z^{(i)}) Qi(z(i))的计算公式就是后验概率,即:我们假定了参数就是 θ \theta θ , 那么每个样本 x ( i ) x^{(i)} x(i)属于各个类的概率会是多少。这一步就是E步,建立 logL(θ)的下界

接下来的M步,就是在给定 Q i ( z ( i ) ) Q_i(z^{(i)}) Qi(z(i))后,调整 θ θ θ,去极大化 l o g L ( θ ) logL(θ) logL(θ) 的下界

EM算法步骤

1、初始化分布参数 θ; 重复E、M步骤直到收敛:
2、E步骤:根据现在的参数θ,来计算出隐性变量(如类别)的后验概率(即隐性变量的期望),作为隐性变量的现估计值
在这里插入图片描述
3、M步骤:将似然函数最大化以获得新的参数值 θ \theta θ,即更新 θ \theta θ在这里插入图片描述

举例

两种硬币,但是两个硬币的材质不同导致其出现正反面的概率不一样。目前我们只有一组观测数据,要求出每一种硬币投掷时正面向上的概率。总共投了五轮,每轮投掷五次
1、现在先考虑一种简单的情况,假设我们知道这每一轮用的是哪一个硬币去投掷的:
在这里插入图片描述
那么我们拿着这样的一组数据,就可以很轻松的估计出A硬币和B硬币出现正面的概率,如下:
P A = ( 3 + 1 + 2 ) / 15 = 0.4 P B = ( 2 + 3 ) / 10 = 0.5 PA = (3+1+2)/ 15 = 0.4\\ PB=(2+3)/10 = 0.5 PA=(3+1+2)/15=0.4PB=(2+3)/10=0.5
2、现在把问题变得复杂一点,假设我们不知道每一次投掷用的是哪一种硬币,等于是现在的问题加上了一个隐变量,就是每一次选取的硬币的种类。
在这里插入图片描述
那么现在可以想一想,假设我们把每一次硬币的种类设为z,则这五次实验生成了一个5维的向量 ( z 1 , z 2 , z 3 , z 4 , z 5 ) (z1,z2,z3,z4,z5) (z1,z2,z3,z4,z5),现在问题来了,如果我们要根据观测结果去求出PA,PB,那么首先需要知道z,但是如果用最大似然估计去估计z,又要先求出PA,PB。这就产生了一个循环。

那么这个时候EM算法的作用就体现出来了! EM算法的基本思想是:先初始化一个PA,PB(就是上文的 θ \theta θ),然后我们拿着这个初始化的PA,PB用最大似然概率估计出z,接下来有了z之后就用z去计算出在当前z的情况下的PA,PB是多少,然后不断地重复这两个步骤直到收敛。

有了这个思想之后现在用这个思想来做一下这个例子,假设初始状态下PA=0.2, PB=0.7,然后我们根据这个概率去估计出z
在这里插入图片描述
标粗体的是按最大似然估计,最有可能的硬币种类。
按照最大似然估计,z=(B,A,A,B,A),有了z之后我们反过来重新估计一下PA,PB:
PA = (2+1+2)/15 = 0.33
PB =(3+3)/10 = 0.6

可以看到PA,PB的值已经更新了,假设PA,PB的真实值0.4和0.5,那么你在不断地重复这两步你就会发现PA,PB在不断地靠近这两个真实值。

最后

EM算法在GMM、K-means中有应用。之后再讲这两个模型。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
刚找到的书,第二版的.. 【原书作者】: Geoffrey J. McLachlan, Thriyambakam Krishnan 【ISBN 】: ISBN-10: 0471201707 / ISBN-13: 978-0471201700 【页数 】:360 【开本 】 : 【出版社】 :Wiley-Interscience 【出版日期】:March 14, 2008 【文件格式】:DJVU(请去网上下载windjview阅读 【摘要或目录】: Review "...should be comprehensible to graduates with statistics as their major subject." (Quarterly of Applied Mathematics, Vol. LIX, No. 3, September 2001) --This text refers to the Hardcover edition. Book Description The EM Algorithm and Extensions remains the only single source to offer a complete and unified treatment of the theory, methodology, and applications of the EM algorithm. The highly applied area of statistics here outlined involves applications in regression, medical imaging, finite mixture analysis, robust statistical modeling, survival analysis, and repeated-measures designs, among other areas. The text includes newly added and updated results on convergence, and new discussion of categorical data, numerical differentiation, and variants of the EM algorithm. It also explores the relationship between the EM algorithm and the Gibbs sampler and Markov Chain Monte Carlo methods. About Authors Geoffrey J. McLachlan, PhD, DSc, is Professor of Statistics in the Department of Mathematics at The University of Queensland, Australia. A Fellow of the American Statistical Association and the Australian Mathematical Society, he has published extensively on his research interests, which include cluster and discriminant analyses, image analysis, machine learning, neural networks, and pattern recognition. Dr. McLachlan is the author or coauthor of Analyzing Microarray Gene Expression Data, Finite Mixture Models, and Discriminant Analysis and Statistical Pattern Recognition, all published by Wiley. Thriyambakam Krishnan, PhD, is Chief Statistical Architect, SYSTAT Software at Cranes Software International Limited in Bangalore, India. Dr. Krishnan has over forty-five years of research, teaching, consulting, and software development experience at the Indian Statistical Institute (ISI). His research interests include biostatistics, image analysis, pattern recognition, psychometry, and the EM algorithm. 目录 Preface to the Second Edition. Preface to the First Edition. List of Examples. 1. General Introduction. 1.1 Introduction. 1.2 Maximum Likelihood Estimation. 1.3 Newton-Type Methods. 1.4 Introductory Examples. 1.5 Formulation of the EM Algorithm. 1.6 EM Algorithm for MAP and MPL Estimation. 1.7 Brief Summary of the Properties of EM Algorithm. 1.8 History of the EM Algorithm. 1.9 Overview of the Book. 1.10 Notations. 2. Examples of the EM Algorithm. 2.1 Introduction. 2.2 Multivariate Data with Missing Values. 2.3 Least Square with the Missing Data. 2.4 Example 2.4: Multinomial with Complex Cell Structure. 2.5 Example 2.5: Analysis of PET and SPECT Data. 2.6 Example 2.6: Multivariate t-Distribution (Known D.F.). 2.7 Finite Normal Mixtures. 2.8 Example 2.9: Grouped and Truncated Data. 2.9 Example 2.10: A Hidden Markov AR(1) Model. 3. Basic Theory of the EM Algorithm. 3.1 Introduction. 3.2 Monotonicity of a Generalized EM Algorithm. 3.3 Monotonicity of a Generalized EM Algorithm. 3.4 Convergence of an EM Sequence to a Stationary Value. 3.5 Convergence of an EM Sequence of Iterates. 3.6 Examples of Nontypical Behavior of an EM (GEM) Sequence. 3.7 Score Statistic. 3.8 Missing Information. 3.9 Rate of Convergence of the EM Algorithm. 4. Standard Errors and Speeding up Convergence. 4.1 Introduction. 4.2 Observed Information Matrix. 4.3 Approximations to Observed Information Matrix: i.i.d. Case. 4.4 Observed Information Matrix for Grouped Data. 4.5 Supplemented EM Algorithm. 4.6 Bookstrap Approach to Standard Error Approximation. 4.7 Baker’s, Louis’, and Oakes’ Methods for Standard Error Computation. 4.8 Acceleration of the EM Algorithm via Aitken’s Method. 4.9 An Aitken Acceleration-Based Stopping Criterion. 4.10 conjugate Gradient Acceleration of EM Algorithm. 4.11 Hybrid Methods for Finding the MLE. 4.12 A GEM Algorithm Based on One Newton-Raphson Algorithm. 4.13 EM gradient Algorithm. 4.14 A Quasi-Newton Acceleration of the EM Algorithm. 4.15 Ikeda Acceleration. 5. Extension of the EM Algorithm. 5.1 Introduction. 5.2 ECM Algorithm. 5.3 Multicycle ECM Algorithm. 5.4 Example 5.2: Normal Mixtures with Equal Correlations. 5.5 Example 5.3: Mixture Models for Survival Data. 5.6 Example 5.4: Contingency Tables with Incomplete Data. 5.7 ECME Algorithm. 5.8 Example 5.5: MLE of t-Distribution with the Unknown D.F. 5.9 Example 5.6: Variance Components. 5.10 Linear Mixed Models. 5.11 Example 5.8: Factor Analysis. 5.12 Efficient Data Augmentation. 5.13 Alternating ECM Algorithm. 5.14 Example 5.9: Mixtures of Factor Analyzers. 5.15 Parameter-Expanded EM (PX-EM) Algorithm. 5.16 EMS Algorithm. 5.17 One-Step-Late Algorithm. 5.18 Variance Estimation for Penalized EM and OSL Algorithms. 5.19 Incremental EM. 5.20 Linear Inverse problems. 6. Monte Carlo Versions of the EM Algorithm. 6.1 Introduction. 6.2 Monte Carlo Techniques. 6.3 Monte Carlo EM. 6.4 Data Augmentation. 6.5 Bayesian EM. 6.6 I.I.D. Monte Carlo Algorithm. 6.7 Markov Chain Monte Carlo Algorithms. 6.8 Gibbs Sampling. 6.9 Examples of MCMC Algorithms. 6.10 Relationship of EM to Gibbs Sampling. 6.11 Data Augmentation and Gibbs Sampling. 6.12 Empirical Bayes and EM. 6.13 Multiple Imputation. 6.14 Missing-Data Mechanism, Ignorability, and EM Algorithm. 7. Some Generalization of the EM Algorithm. 7.1 Introduction. 7.2 Estimating Equations and Estimating Functions. 7.3 Quasi-Score and the Projection-Solution Algorithm. 7.4 Expectation-Solution (ES) Algorithm. 7.5 Other Generalization. 7.6 Variational Bayesian EM Algorithm. 7.7 MM Algorithm. 7.8 Lower Bound Maximization. 7.9 Interval EM Algorithm. 7.10 Competing Methods and Some Comparisons with EM. 7.11 The Delta Algorithm. 7.12 Image Space Reconstruction Algorithm. 8. Further Applications of the EM Algorithm. 8.1 Introduction. 8.2 Hidden Markov Models. 8.3 AIDS Epidemiology. 8.4 Neural Networks. 8.5 Data Mining. 8.6 Bioinformatics. References. Author Index. Subject Index

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值