fitting sum of gaussians into a data set (100 rows and 1 column)

8 vues (au cours des 30 derniers jours)
Abhishek
Abhishek le 10 Juin 2013
Getting difficulty in fitting and plotting a data set (100x1 matrix) by using gmdistribution.fit....i have to git a large number of sum of gaussians...but i guess it needs a matrix with mu and sigma values...can anyone help me in fitting this data into sum of gaussians and plotting it..i want a one dimensional plot... thanks

Réponse acceptée

Pourya Alinezhad
Pourya Alinezhad le 10 Juin 2013
you can use the function "lsqcurvefit".first define Gaussian formula in a function mfile.then the lsqcurvefit function gives the fitted data .
  3 commentaires
Pourya Alinezhad
Pourya Alinezhad le 10 Juin 2013
what is your understanding that "large number of gaussians"? if there is multiple qaussian functions with variable mu and sigma values you can do so for every of them and then interpolate the results to have one dimentional plot or take an average between the results.
Abhishek
Abhishek le 14 Juin 2013
Modifié(e) : Abhishek le 14 Juin 2013
I am using 15 gaussians. I have an one dimensional data set [101,1].its not fitting efficiently using lsqcurvefit
This is the command X = lsqcurvefit(@FUN,X0,x,y,[],[],options); where,
1)function ret= FUN(X,x) F=zeros(101,1); for i=1:15, F=F+ X(i,1)*exp((-(x-X(15+i,1))./X(30+i,1)).^2); end ret=F; return
2) X0=ones(3*15,1)/1;
3) x=[0:0.01:1]';
4) y=12*exp(-abs(x-0.00001)/.01)+8*exp(-abs(x-0.5)/.01)+12*exp(-abs(x-1)/.01); rmic=zeros(siz,20); h=[1:1:20]'; for i=1:siz;for j=1:20; rmic(i,j)=cos(2*pi*j*x(i));end;end; fore=rmic'*y;
5)options = optimset('TolX',1e-8,'Display','iter','MaxIter',1000000,'TolFun',1e-10,'MaxFunEvals',10000000,'DiffMaxChange',.1000,'LineSearchType','cubicpoly');
My data sets are : y (x): [ 11.9880 4.4190 1.6256 0.5980 0.2200 0.0809 0.0298 0.0110 0.0040 0.0015 0.0005 0.0002 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0004 0.0010 0.0027 0.0073 0.0198 0.0539 0.1465 0.3983 1.0827 2.9430 8.0000 2.9430 1.0827 0.3983 0.1465 0.0539 0.0198 0.0073 0.0027 0.0010 0.0004 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0002 0.0005 0.0015 0.0040 0.0109 0.0297 0.0809 0.2198 0.5974 1.6240 4.4146 12.0000]
and as mentioned, x=[0:0.01:1]';
I am not able to get the correct curve fit......is it the initial guess, X0.....or anything else.....please help me out...I am stuck on this..
thanks,

Connectez-vous pour commenter.

Plus de réponses (1)

Alan Weiss
Alan Weiss le 14 Juin 2013
Modifié(e) : Alan Weiss le 14 Juin 2013
As clearly stated in the Input Arguments section of the documentation, you should not return the sum of squares, but should return a vector of values for your objective function. Making a sum of squares as you have done slows or stops convergence.
I am not sure that I understand your formulation completely, but perhaps you should check a similar sort of example in the documentation.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 commentaire
Abhishek
Abhishek le 14 Juin 2013
Well I am taking sum of Gaussian in the function...I mean is there any other way to use the sum of Gaussian to fit..

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by