Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

plot 2 gaussians obtained by gmdistribution.fit

489 views
Skip to first unread message

Marcos Belmonte

unread,
Mar 12, 2012, 4:59:12 AM3/12/12
to
Hi, I'm using gmdistribution.fit to obtain two gaussians in order to contrast my homogeneous image.The information I obtain is:

Mixing proportion: 0.461726
Mean: 195.8348

Component 2:
Mixing proportion: 0.538274
Mean: 68.9320

How could I represent the two gaussians in order to obtain the standard deviation of each gaussian at the bottom (base))?

Thanks

Marcos Belmonte

unread,
Mar 12, 2012, 5:10:14 AM3/12/12
to
"Marcos Belmonte" <marco...@gmail.com> wrote in message <jjkdt0$9el$1...@newscl01ah.mathworks.com>...
> Hi, I'm using gmdistribution.fit to obtain two gaussians in order to contrast my homogeneous image. The data are from an histogram. The information I obtain is:

Marcos Belmonte

unread,
Mar 12, 2012, 5:29:12 AM3/12/12
to
"Marcos Belmonte" <marco...@gmail.com> wrote in message <jjkehm$bdq$1...@newscl01ah.mathworks.com>...
The data are from an histogram so I have a unidimensional object. Is there a way to represent with pdf o cdf like ezsurf(@(x,y)pdf(obj,[x y]),[-10 10],[-10 10]) in http://www.mathworks.es/help/toolbox/stats/brklrj3.html#brklr93-1?

Thanks

Tom Lane

unread,
Mar 12, 2012, 10:51:49 AM3/12/12
to
>> > Hi, I'm using gmdistribution.fit to obtain two gaussians in order to
>> > contrast my homogeneous image. The data are from an histogram. The
>> > information I obtain is:
..
>> > How could I represent the two gaussians in order to obtain the standard
>> > deviation of each gaussian at the bottom (base))?

If G is your fitted object, then G.Sigma is an array of the covariances. The
standard deviations are the square roots of the diagonal elements. Note this
is a 3-D array and you have 1-D data apparently, so you may find it
convenient to use squeeze(G.Sigma) to get a vector of the two variances.

> The data are from an histogram so I have a unidimensional object. Is there
> a way to represent with pdf o cdf like ezsurf(@(x,y)pdf(obj,[x y]),[-10
> 10],[-10 10]) in
> http://www.mathworks.es/help/toolbox/stats/brklrj3.html#brklr93-1?

I don't understand this question, but pdf(G,x) is the mixture pdf evaluated
at x. You could plot this on top of a histogram if you scale the histogram
to have total area 1.

-- Tom

philb

unread,
Apr 24, 2012, 11:53:07 AM4/24/12
to
"Tom Lane" <tl...@mathworks.com> wrote in message <jjl2i5$gtm$1...@newscl01ah.mathworks.com>...
and how could I just plot one of the two gaussians with pdf ?

Tom Lane

unread,
Apr 25, 2012, 3:28:24 PM4/25/12
to
> and how could I just plot one of the two gaussians with pdf ?

Take a look at the following, which plots the mixture distribution then the
two separate Gaussians individually:

load fisheriris
x = meas(:,1);
gm = gmdistribution.fit(x,2)
xx = linspace(4,8)';

plot(xx,pdf(gm,xx))

for j=1:2
line(xx,gm.PComponents(j)*normpdf(xx,gm.mu(j),sqrt(gm.Sigma(j))),'color','r')
end

-- Tom

0 new messages