Prev: Uimenu Icon
Next: colorbarf, pcolor plot
From: olsonaj on 14 May 2010 12:27 Hello, I am looking to use Matlab to fit experimental 1D data with a Gaussian bimodal distribution. I've been looking into the gmdistribution fit that Matlab provides, but have been unable to discover a way to make it work with 1D (univariate) data; I keep getting error messages whenever I change their bivariate example to 1D. Is it possible with that? If not, is there something else that may work? Thanks,
From: olsonaj on 14 May 2010 13:16 Figured it out. To do this, use muA = [0;0]; sigmaA = cat(3,[100],[0.5]); objA = gmdistribution(muA,sigmaA); xRangeA = transpose(linspace(-2,2,80)); plot(xRangeA,pdf(objA,xRangeA)) where the 100 and 0.5 are the waist^2 of the two components.
From: Peter Perkins on 14 May 2010 13:23 On 5/14/2010 12:27 PM, olsonaj wrote: > Hello, > > I am looking to use Matlab to fit experimental 1D data with a Gaussian > bimodal distribution. > Figured it out. To do this, use > > muA = [0;0]; > sigmaA = cat(3,[100],[0.5]); > > objA = gmdistribution(muA,sigmaA); This actually doesn't "fit" anything. Have you looked at >> help gmdistribution/fit FIT Fit a Gaussian mixture distribution to data.
From: olsonaj on 14 May 2010 13:42 > This actually doesn't "fit" anything. True, and that leads up to the second part of my question. Here's my code I've used to try to fit a bimodal univariate distribution (sTrapPot1 is y-axis experimental data, where plotGx is the x axis): options = statset('Display','final'); objB = gmdistribution.fit(sTrapPot1,2); subplot(2,1,1) plot(plotGx,pdf(objB,plotGx)) subplot(2,1,2) plot(plotGx,sTrapPot1); Unfortunately, Matlab's fit is entirely off. My bimodal distribution data is very clean (I can send if someone wants to take a look) so I'm very confused as to why this doesn't work. Anything stand out as an error?
From: Tom Lane on 14 May 2010 15:16
You have two variables, plotGx and sTrapPot1. Your last command suggests to me that these are not data following a binomodal distribution. It looks like they are the output from the hist function, or some other representation of a density perhaps. The gmdistribution.fit expects you to provide it with data following a mixture distribution. Do you have the original data for which sTrapPot1 is a summary? If not, you may be trying to fit a curve rather than fit a distribution. Take a look here: http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/cfitdfitdemo.html But I recommend fitting the distribution to the raw data, if you have that available. -- Tom "olsonaj" <abraham.olson(a)gmail.com> wrote in message news:f11542dd-cc6c-4ee1-a1be-83b94c1b6858(a)c13g2000vbr.googlegroups.com... > >> This actually doesn't "fit" anything. > > > True, and that leads up to the second part of my question. > > Here's my code I've used to try to fit a bimodal univariate > distribution (sTrapPot1 is y-axis experimental data, where plotGx is > the x axis): > > options = statset('Display','final'); > objB = gmdistribution.fit(sTrapPot1,2); > > subplot(2,1,1) > plot(plotGx,pdf(objB,plotGx)) > subplot(2,1,2) > plot(plotGx,sTrapPot1); > > Unfortunately, Matlab's fit is entirely off. My bimodal distribution > data is very clean (I can send if someone wants to take a look) so I'm > very confused as to why this doesn't work. > > Anything stand out as an error? > > > |