Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
plot 2 gaussians obtained by gmdistribution.fit

Subject: plot 2 gaussians obtained by gmdistribution.fit

From: Marcos Belmonte

Date: 12 Mar, 2012 08:59:12

Message: 1 of 6

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

Subject: plot 2 gaussians obtained by gmdistribution.fit

From: Marcos Belmonte

Date: 12 Mar, 2012 09:10:14

Message: 2 of 6

"Marcos Belmonte" <marcosbelm@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:
>
> 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

Subject: plot 2 gaussians obtained by gmdistribution.fit

From: Marcos Belmonte

Date: 12 Mar, 2012 09:29:12

Message: 3 of 6

"Marcos Belmonte" <marcosbelm@gmail.com> wrote in message <jjkehm$bdq$1@newscl01ah.mathworks.com>...
> "Marcos Belmonte" <marcosbelm@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:
> >
> > 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

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

Subject: plot 2 gaussians obtained by gmdistribution.fit

From: Tom Lane

Date: 12 Mar, 2012 14:51:49

Message: 4 of 6

>> > 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

Subject: plot 2 gaussians obtained by gmdistribution.fit

From: philb

Date: 24 Apr, 2012 15:53:07

Message: 5 of 6

"Tom Lane" <tlane@mathworks.com> wrote in message <jjl2i5$gtm$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:
> ..
> >> > 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

and how could I just plot one of the two gaussians with pdf ?

Subject: plot 2 gaussians obtained by gmdistribution.fit

From: Tom Lane

Date: 25 Apr, 2012 19:28:24

Message: 6 of 6

> 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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us