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:
Generating Two dimensional normal distribution

Subject: Generating Two dimensional normal distribution

From: Adshak

Date: 23 Feb, 2009 01:51:11

Message: 1 of 4

Dear All,

I am looking at functions that can help in plotting two dimensional
Gaussians.

Now what I exactly want is the bidimensional or bivariate equivalent
of:

normrnd(mu,sigma,M,N)

and

normpdf(X,mu,sigma)


This function can be something like:

Norm2rnd(mu_x,mu_y,sigma_x,sigma_y,M,N)

and

Norm2pdf(X,Y,mu_x,mu_y,sigma_x,sigma_y)


Any help on this is greatly appreciated.

Subject: Generating Two dimensional normal distribution

From: Roger Stafford

Date: 23 Feb, 2009 02:54:01

Message: 2 of 4

Adshak <adshaikh.hipnet@googlemail.com> wrote in message <1b67c5e2-ef95-4630-80ba-e1f897b84c14@m42g2000yqb.googlegroups.com>...
> .......
> I am looking at functions that can help in plotting two dimensional
> Gaussians.
> ......

What you want are 'mvnrnd' and 'mvncdf'. They're also in the Statistics Toolbox.

Roger Stafford

Subject: Generating Two dimensional normal distribution

From: Adshak

Date: 23 Feb, 2009 13:08:58

Message: 3 of 4

On Feb 23, 2:54=A0am, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> Adshak <adshaikh.hip...@googlemail.com> wrote in message <1b67c5e2-ef95-4=
630-80ba-e1f897b84...@m42g2000yqb.googlegroups.com>...
> > .......
> > I am looking at functions that can help in plotting two dimensional
> > Gaussians.
> > ......
>
> What you want are 'mvnrnd' and 'mvncdf'. =A0They're also in the Statistic=
s Toolbox.
>
> Roger Stafford


Thanks so much, I have however one problem trying to use mvnpdf to
visualise the 2dimensional Gaussian or Normal Peak on a 3d plot.

So for example:

If mu =3D [0,0];
SIGMA =3D [.9 .4; .4 .3];
X=3D[-4:0.1:4];
Y=3D[-4:0.1:4];

z =3D [X;Y];

p=3Dmvnpdf(z,mu,SIG);

Now I wanted to plot a three dimensional Gaussian peak by using
something like:

surf(X,Y,p);

But ofcourse here p needs to be a matrix which is not what I get. How
can I make p a matrix form for all possible combination of values of X
and Y, so that I can plot it using surf or mesh?

Any hint on how to achieve this, will be very beneficial to me. Can I
use meshgrid for this case? if so how?

Many thanks,

Adshak

Subject: Generating Two dimensional normal distribution

From: Adshak

Date: 23 Feb, 2009 15:30:49

Message: 4 of 4

On Feb 23, 1:08=A0pm, Adshak <adshaikh.hip...@googlemail.com> wrote:
> On Feb 23, 2:54=A0am, "Roger Stafford"
>
> <ellieandrogerxy...@mindspring.com.invalid> wrote:
> > Adshak <adshaikh.hip...@googlemail.com> wrote in message <1b67c5e2-ef95=
-4630-80ba-e1f897b84...@m42g2000yqb.googlegroups.com>...
> > > .......
> > > I am looking at functions that can help in plotting two dimensional
> > > Gaussians.
> > > ......
>
> > What you want are 'mvnrnd' and 'mvncdf'. =A0They're also in the Statist=
ics Toolbox.
>
> > Roger Stafford
>
> Thanks so much, I have however one problem trying to use mvnpdf to
> visualise the 2dimensional Gaussian or Normal Peak on a 3d plot.
>
> So for example:
>
> If mu =3D [0,0];
> SIGMA =3D [.9 .4; .4 .3];
> X=3D[-4:0.1:4];
> Y=3D[-4:0.1:4];
>
> z =3D [X;Y];
>
> p=3Dmvnpdf(z,mu,SIG);
>
> Now I wanted to plot a three dimensional Gaussian peak =A0by using
> something like:
>
> surf(X,Y,p);
>
> But ofcourse here p needs to be a matrix which is not what I get. How
> can I make p a matrix form for all possible combination of values of X
> and Y, so that I can plot it using surf or mesh?
>
> Any hint on how to achieve this, will be very beneficial to me. Can I
> use meshgrid for this case? if so how?
>
> Many thanks,
>
> Adshak

Ok I got it now. Thanks a lot anyway....

Adshak

Tags for this Thread

No tags are associated with 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