필터 지우기
필터 지우기

How do I plot a gaussian mixed model with 1D data?

조회 수: 9 (최근 30일)
Trisha Kibaya
Trisha Kibaya 2018년 8월 19일
댓글: Sajid Raza 2019년 7월 31일
Hi I am a novice in Matlab. I have to plot a gaussian mixed model with one dimensional data. So far i have been able to do only this: data = xlsread('csf.xlsx','ab'); mu1 = mean('data'); sigma1 = std('data'); X = [mvnrnd(mu1,sigma1,1000)]; gm = fitgmdist(X,2); What do i do next? Thanks a lot.
  댓글 수: 1
Sajid Raza
Sajid Raza 2019년 7월 31일
@Trisha Kibaya, did you get answer for this one dimensional question?
I am facing same issue. I have one dimensional data. I use 'fitgmdist' to get gmdistribution. Then i want to visualize this distribution or show as clusters based on mu and sigma from the fitgmdist function.
Thanks.

댓글을 달려면 로그인하십시오.

채택된 답변

Yuvaraj Venkataswamy
Yuvaraj Venkataswamy 2018년 8월 20일
if true
data = xlsread('csf.xlsx','ab'); % your data
mu1 = mean('data'); % mean
sigma1 = std('data'); % standard deviation
X = [mvnrnd(mu1,sigma1,1000)]; % generate equal number of random variables
gm = fitgmdist(X,2); %Gaussian mixture distribution with 2 components
scatter(X(:,1),X(:,2),10,'.') % plot X
hold on
ezcontour(@(x,y)pdf(gm,[x y]),[-8 6],[-8 6])
end
From the plot You can visualize the fitted model gm by using pdf and ezcontour of your data.
  댓글 수: 2
Trisha Kibaya
Trisha Kibaya 2018년 8월 20일
Thanks for your reply. I did as you suggested and I got the following error message: Index in position 2 exceeds array bounds (must not exceed 1). Do you know which position its referring to? and is there a way to plot it like a bell curve?
Yuvaraj Venkataswamy
Yuvaraj Venkataswamy 2018년 8월 20일
In which line you are getting error?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Trisha Kibaya
Trisha Kibaya 2018년 8월 20일
I have attached a screenshot.

Community Treasure Hunt

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

Start Hunting!

Translated by