Using fitgmdist on a Histogram

7 visualizzazioni (ultimi 30 giorni)
Douglas Bock
Douglas Bock il 7 Dic 2018
Risposto: Alfredo Dinho il 26 Mag 2021
I have a Histogram in which I want to find the peaks of a mixture of gaussians (see attached .fig file).
The Histogram shows 4 clear peaks of which I need to know the centres.
However, I can not get fitgmdist to properly fit gaussians. It does perform some kind of fit, but returns mu and Sigma with strange, impossible values!
I have also attached a MWE for reproducibilty.
I believe I am confused as to what the first argument to fitgmdist has to be.
This is a one dimensional problem, and Mathworks examples all deal with higher dimensional problems which I have difficulty to reduce.FSC_Histogram.png

Risposte (2)

Image Analyst
Image Analyst il 7 Dic 2018
Fit the count data with fitnlm. I attach a demo for two Gaussians. Make the obvious adaptations for 4 Gaussians.
0000 Screenshot.png
  2 Commenti
Douglas Bock
Douglas Bock il 11 Dic 2018
Many thanks Image Analyst!
I have previously considered hardcoding the GMM function to fit the data.
However, I may have anything between 1 and 10 peaks for which I need the gaussians. This would require me to hardcode 10 different GMM, which, although doable, would make the fitgmdist function redundant. I want to exploit that one of the arguements for fitgmdist is the number of peaks to be detected...
Image Analyst
Image Analyst il 11 Dic 2018
Another option is to use the clean algorithm. The strategy astronomers use in finding stars is the "Clean" algorithm. Take largest peak, fit it, subtract from the data to get new data, and then iterate on all the smaller remaining peaks until you've gotten to peaks so small thatyou want to stop. I suppose it works okay empirically but I gotta think there's a fancier, mathematically accurate way. Though things are harder in 2-D - it's not just a straightforward extension of the 1-D case.

Accedi per commentare.


Alfredo Dinho
Alfredo Dinho il 26 Mag 2021
Hello my friend! You just have to transpose the matrix ... see: I ran here and it worked perfectly ..
fitData = fitData + p(n)*normpdf(binCenters,mu(n),sig(n))';

Community Treasure Hunt

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

Start Hunting!

Translated by