How to fit multiple gaussians over a 3-D histogram

5 vues (au cours des 30 derniers jours)
JOO WON,HEE
JOO WON,HEE le 1 Juil 2015
Commenté : JOO WON,HEE le 1 Juil 2015
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.

Réponse acceptée

Bjorn Gustavsson
Bjorn Gustavsson le 1 Juil 2015
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 commentaire
JOO WON,HEE
JOO WON,HEE le 1 Juil 2015
I didn't get this can you please elaborate. Thank You

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by