pdf for multivariate normal function?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

pdf for multivariate normal function?

per freem-2
hi all,

i'm trying to find the function for the pdf of a multivariate normal pdf. i know that the function "multivariate_normal" can be used to sample from the multivariate normal distribution, but i just want to get the pdf for a given vector of means and a covariance matrix. is there a function to do this?

thank you.
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: pdf for multivariate normal function?

Charles R Harris


On Thu, Jul 23, 2009 at 7:14 AM, per freem <[hidden email]> wrote:
hi all,

i'm trying to find the function for the pdf of a multivariate normal pdf. i know that the function "multivariate_normal" can be used to sample from the multivariate normal distribution, but i just want to get the pdf for a given vector of means and a covariance matrix. is there a function to do this?

Well, what does a pdf mean in the multidimensional case? One way to convert the density function into a Stieltjes type measure is to plot the integral over a polytope with one corner at [-inf, -inf,....] and the diagonally opposite corner at the plotting point, but the multidimensional display of the result might not be very informative. What do you actually want here?

Chuck


_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: pdf for multivariate normal function?

Andrew Jaffe-4
Hi,

Charles R Harris wrote:

>
> On Thu, Jul 23, 2009 at 7:14 AM, per freem <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     i'm trying to find the function for the pdf of a multivariate normal
>     pdf. i know that the function "multivariate_normal" can be used to
>     sample from the multivariate normal distribution, but i just want to
>     get the pdf for a given vector of means and a covariance matrix. is
>     there a function to do this?
>
> Well, what does a pdf mean in the multidimensional case? One way to
> convert the density function into a Stieltjes type measure is to plot
> the integral over a polytope with one corner at [-inf, -inf,....] and
> the diagonally opposite corner at the plotting point, but the
> multidimensional display of the result might not be very informative.
> What do you actually want here?

You are confusing PDF (Probability Density Functions) with CDF
(Cumulative Density Function), I think. The PDF is well-defined for
multivariate distributions. It is defined so that P(x) dx is the
probability to be in the infinitesimal range (x,x+dx).

For a multivariate gaussian, it's

P(x|m, C) = [1/det(2 pi C)] exp{ -1/2 (x-m)^T C^{-1} (x-m) }

in matrix notation, where m is the mean and C is the covariance matrix.

Andrew

















_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: pdf for multivariate normal function?

cdavid
In reply to this post by per freem-2
per freem wrote:
> hi all,
>
> i'm trying to find the function for the pdf of a multivariate normal
> pdf. i know that the function "multivariate_normal" can be used to
> sample from the multivariate normal distribution, but i just want to
> get the pdf for a given vector of means and a covariance matrix. is
> there a function to do this?

AFAIK, there is no such function in scipy. There is one in the em
subpackage of the learn scikits. The file which implements it is
self-contained, so you could use this in the meantime:

http://projects.scipy.org/scikits/browser/trunk/learn/scikits/learn/machine/em/densities.py

I wrote this code some time ago, so it is not optimal in various ways,
but it should get the job done.

cheers,

David
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion