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:
How to draw normal probability density function for 3d vector

Subject: How to draw normal probability density function for 3d vector

From: kumar vishwajeet

Date: 10 Sep, 2010 03:47:24

Message: 1 of 3

Hi all,
I want to draw normal probability density function for the following data:
x = 3 x 10 array
mu = 3 x 1 vector
sigma = eye(3)

Normpdf(x,mu,sigma) gives error as it requires all the arguments of the same size.
thanks.

Subject: How to draw normal probability density function for 3d vector

From: kumar vishwajeet

Date: 10 Sep, 2010 04:55:05

Message: 2 of 3

"kumar vishwajeet" <kwzeet@gmail.com> wrote in message <i6c9oc$kds$1@fred.mathworks.com>...
> Hi all,
> I want to draw normal probability density function for the following data:
> x = 3 x 10 array
> mu = 3 x 1 vector
> sigma = eye(3)
>
> Normpdf(x,mu,sigma) gives error as it requires all the arguments of the same size.
> thanks.

I think I got it:-

[X1,X2,X3] = meshgrid(x(1,:),x(2,:),x(3,:));
F = mvnpdf([X1(:) X2(:) X3(:)],mu,Sigma);

Now the only problem is that I cannot draw it, as it has 4 dimensions i.e. X1,X2,X3 and F. :(

Subject: How to draw normal probability density function for 3d vector

From: Peter Perkins

Date: 10 Sep, 2010 05:32:53

Message: 3 of 3

On 9/9/2010 11:47 PM, kumar vishwajeet wrote:
> Hi all,
> I want to draw normal probability density function for the following data:
> x = 3 x 10 array
> mu = 3 x 1 vector
> sigma = eye(3)
>
> Normpdf(x,mu,sigma) gives error as it requires all the arguments of the
> same size.

NORMPDF is for the univariate normal distribution. You don't say, but
based on what you have for sigma, it appears that you are talking about
a multivariate normal distribution, in three dimensions. So you want
MVNPDF, not NORMPDF. Your data have the wrong orientation, though.
Assuming you're in 3 dims, then mu needs to be a 1x3 row vector, and x
needs to be a 10x3 matrix. MVNPDF does allow mu to be a single vector
and sigma to be a single matrix, though it also allows you to specify a
different mean and cov for each row of x. This is all described in the
help.

If you want a 1D normal distribution, then you'll need to explain.

Hope this helps.

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