フィルターのクリア

How to plot a Gaussian of mixture to a data?

3 ビュー (過去 30 日間)
Amr Hashem
Amr Hashem 2017 年 3 月 25 日
回答済み: Amr Hashem 2017 年 3 月 26 日
I want to construct and 1D plot a uni-variate Gaussian Mixture with say four components where I already have its parameters including mu,sigma,components. I am using this code:
numComponents=4;
paramEsts= gmdistribution.fit(Life,numComponents)
xgrids = linspace(0,173,100);
MU=[paramEsts.mu(1);paramEsts.mu(2);paramEsts.mu(3);paramEsts.mu(4)];
SIGMA=cat(3,[paramEsts.Sigma(1)],[paramEsts.Sigma(2)],[paramEsts.Sigma(3)],[paramEsts.Sigma(4)]);
Pp=[1;2;3;4];
obj=gmdistribution(MU,SIGMA,Pp)
Note: I am using (gmdistribution.fit) as i have matlab 2009 and i didn't have the statistical tool box

採用された回答

Amr Hashem
Amr Hashem 2017 年 3 月 26 日
I got it
numComponents=4;
paramEsts= gmdistribution.fit(Life,numComponents)
MU=[paramEsts.mu(1);paramEsts.mu(2);paramEsts.mu(3);paramEsts.mu(4)];
SIGMA=cat(3,[paramEsts.Sigma(1)],[paramEsts.Sigma(2)],[paramEsts.Sigma(3)],[paramEsts.Sigma(4)]);
PPp=[paramEsts.PComponents(1),paramEsts.PComponents(2),paramEsts.PComponents(3),paramEsts.PComponents(4)];
objA = gmdistribution(MU,SIGMA,PPp);
xgridss=transpose(linspace(0,173,100));
plot(xgridss,pdf(objA,xgridss),'r-','linewidth',2)
That work.

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by