Gaussian Mixture pdf plot

18 ビュー (過去 30 日間)
freebil
freebil 2016 年 6 月 18 日
回答済み: the cyclist 2017 年 1 月 12 日
Hello. I have a gaussian with probability 0.2 and (m1,sigma1), another with probability 0.3 and (m2,sigma2) and one with probability 0.5 and (m3,sigma3).
How can I plot this? Thanks.

回答 (3 件)

the cyclist
the cyclist 2016 年 6 月 18 日
編集済み: the cyclist 2016 年 6 月 18 日

Here's one way.

pd2 = makedist('Normal','mu',2,'sigma',0.2);
pd3 = makedist('Normal','mu',3,'sigma',0.3);
pd5 = makedist('Normal','mu',5,'sigma',0.5);
x = 0 : 0.001 : 10;
y = 0.2*pdf(pd2,x) + 0.3*pdf(pd3,x) + 0.5*pdf(pd5,x);
figure
plot(x,y)

It requires the Statistics and Machine Learning Toolbox.


the cyclist
the cyclist 2017 年 1 月 12 日
Here is how the same figure can be made without the Statistics & Machine Learning Toolbox:
mu2 = 2;
mu3 = 3;
mu5 = 5;
sig2 = 0.2;
sig3 = 0.3;
sig5 = 0.5;
n2 = @(x) exp(-(x-mu2).^2/(2*sig2.^2)) ./ (sig2*(2*pi).^0.5);
n3 = @(x) exp(-(x-mu3).^2/(2*sig3.^2)) ./ (sig3*(2*pi).^0.5);
n5 = @(x) exp(-(x-mu5).^2/(2*sig5.^2)) ./ (sig5*(2*pi).^0.5);
x = 0 : 0.001 : 10;
y = 0.2*n2(x) + 0.3*n3(x) + 0.5*n5(x);
figure
plot(x,y)

Amr Hashem
Amr Hashem 2017 年 1 月 10 日
what I could use instead of "makedist" if i didn't have the toolbox?

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by