pdf of multivariate normal
![](https://secure.gravatar.com/avatar/9a86268d4af8e00c5419de66347bf77c.jpg?s=120&d=mm&r=g)
Am I right that this doesn't exist in scipy/numpy? Obviously it isn't too hard to code myself but I was surprised it wasn't there. If it is there, how could I have found it easily? John.
![](https://secure.gravatar.com/avatar/cc7542434b914c66ad1fd0ed4174c651.jpg?s=120&d=mm&r=g)
Have a look at the numpy.random module :
info(numpy.random.multivariate_normal) Return an array containing multivariate normally distributed random numbers with specified mean and covariance.
multivariate_normal(mean, cov) -> random values multivariate_normal(mean, cov, [m, n, ...]) -> random values mean must be a 1 dimensional array. cov must be a square two dimensional array with the same number of rows and columns as mean has elements. The first form returns a single 1-D array containing a multivariate normal. The second form returns an array of shape (m, n, ..., cov.shape[0]). In this case, output[i,j,...,:] is a 1-D array containing a multivariate normal. -- LB
![](https://secure.gravatar.com/avatar/9a86268d4af8e00c5419de66347bf77c.jpg?s=120&d=mm&r=g)
LB wrote:
info(numpy.random.multivariate_normal) Return an array containing multivariate normally distributed random numbers
Thanks but I don't want random variates, I would like to calculate the probability density function.
![](https://secure.gravatar.com/avatar/d5321459a9b36ca748932987de93e083.jpg?s=120&d=mm&r=g)
John Reid wrote:
LB wrote:
info(numpy.random.multivariate_normal) Return an array containing multivariate normally distributed random numbers
Thanks but I don't want random variates, I would like to calculate the probability density function.
I have the same question myself. I found one implementation: scikits.learn.machine.em.densities.gauss_den() Is there a version in scipy (or numpy)? After searching, I think not, but it does seems this belongs in there -- perhaps in scipy.stats. Any reason beyond the usual (lack of time) why it's not there already? -Andrew
![](https://secure.gravatar.com/avatar/af6c39d6943bd4b0e1fde23161e7bb8c.jpg?s=120&d=mm&r=g)
On Mon, Nov 26, 2007 at 07:34:16PM -0800, Andrew Straw wrote:
I have the same question myself. I found one implementation: scikits.learn.machine.em.densities.gauss_den()
Is there a version in scipy (or numpy)? After searching, I think not, but it does seems this belongs in there -- perhaps in scipy.stats. Any reason beyond the usual (lack of time) why it's not there already?
Isn't learn.machine.em.densities.gauss_den used to estimate parameters for Gaussian mixture models? For a multivariate Gaussian, the mean and covariance can be calculated directly. Regards Stéfan
![](https://secure.gravatar.com/avatar/9820b5956634e5bbad7f4ed91a232822.jpg?s=120&d=mm&r=g)
On Mon, Nov 26, 2007 at 07:34:16PM -0800, Andrew Straw wrote:
I have the same question myself. I found one implementation: scikits.learn.machine.em.densities.gauss_den()
Is there a version in scipy (or numpy)? After searching, I think not, but it does seems this belongs in there -- perhaps in scipy.stats. Any reason beyond the usual (lack of time) why it's not there already?
Isn't learn.machine.em.densities.gauss_den used to estimate parameters for Gaussian mixture models? For a multivariate Gaussian, the mean and covariance can be calculated directly. No, it is used to compute the pdf of a multivariate Gaussian, which is
Stefan van der Walt wrote: then used to compute the pdf of mixtures. AFAIK, there is no multivariate facilities in scipy.stats, or did I missed them ? Providing the same facilities as in scipy.stats.distribution for multi-variate would be quite a lot of coding, though I guess. For example, for cdf alone, it is not so easy to compute them generally (but the code is already there for kde if I am right, in the mvn extension). David
participants (5)
-
Andrew Straw
-
David Cournapeau
-
John Reid
-
LB
-
Stefan van der Walt