How to fit multiple gaussians over a 3-D histogram

조회 수: 5 (최근 30일)
JOO WON,HEE
JOO WON,HEE 2015년 7월 1일
댓글: JOO WON,HEE 2015년 7월 1일
I have been trying to fit multiple gaussians over a 3-D histogram (Iris data feature 3 and feature 4) using custom equation in cftool (inbuilt in matlab). But results are not coming good. The gaussians are getting clustered nearby nearby the first gaussian (near the origin). But if I try doing this for only one gaussian (data points are similar to gaussian) then I am getting good results.
I am using custom equation method and writing the equation of family of gaussians. I don't want to use fitgmdist as it gives same results always as we pass the full data but I want to pass data using histogram.

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2015년 7월 1일
I think this should get the job done:
[nHist,xHist] = hist(Data,extra,parameters);
twoGausianFCN = @(pars,x) pars(1)*exp(-(x-pars(2)).^2/pars(3)^2) + ...
pars(4)*exp(-(x-pars(5)).^2/pars(6)^2);
err_fcn = @(pars,fcn,hN,hX) sum((hN - fcn(pars,hX).^2);
par0 = [pick,some,reasonable,start,guess,parameters];
par = fminsearch(@(pars) err_fcn(pars,twoGausianFCN,nHist,xHist),par0);
Obviously you can write a separate function for arbitrarily many Gaussians if you want to have something more flexible, and maybe the efficiency of anonymous functions are still worse than regular functions stored in files, but this should be enough if you need to fit a few histograms...
HTH
  댓글 수: 1
JOO WON,HEE
JOO WON,HEE 2015년 7월 1일
I didn't get this can you please elaborate. Thank You

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by