2012-11-09 18 views
0

我有一個數據(x,y)的直方圖,它是兩個高斯(簡單的情況下,即一維)的混合。爲了得到一個配合到它,我使用plot gmdistribution.fit連同數據

OBJ = gmdistribution.fit(數據,2)

,讓我的

OBJ =

高斯混合含有2個組分在1名維分佈 組分1: 混合比例:0.499387 平均數:-0.4789

組分2: 混合比例:0.500613 平均值:-0.4786

現在,我該如何將它與原始直方圖一起繪製?我知道這兩個環節,但他們不幫我這麼多:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/317868

http://www.mathworks.de/de/help/stats/gmdistribution.fit.html

任何明確的幫助,高度讚賞!

回答

1

我想這可能有點晚,但它已更新在matlabs site。以防萬一

MU1 = [1 2]; 
SIGMA1 = [2 0; 0 .5]; 
MU2 = [-3 -5]; 
SIGMA2 = [1 0; 0 1]; 
X = [mvnrnd(MU1,SIGMA1,1000);mvnrnd(MU2,SIGMA2,1000)]; 

scatter(X(:,1),X(:,2),10,'.') 
hold on 

options = statset('Display','final'); 
obj = gmdistribution.fit(X,2,'Options',options); 
10 iterations, log-likelihood = -7046.78 

h = ezcontour(@(x,y)pdf(obj,[x y]),[-8 6],[-8 6]); 

你可以對使用scatter3的3D做同樣的事情。

enter image description here

enter image description here