Multidimensional Normal pdf in Scipy

Trying to evaluate the scipy function multivariate_normal.pdf, but keep getting errors. MWE:

import numpy as np
from scipy.stats import multivariate_normal as mvnorm

x = np.random.rand(5)
mvnorm.pdf(x)

gives

TypeError: pdf() takes at least 4 arguments (2 given)

docs say that arguments meanand covare optional and that the last axis of the xcomponent labels . Since x.shape= (4L,), everything seems to be kosher. I expect that there will be one number as the output.

+4
source share
1 answer

It seems that these options are not optional.

If I pass the default values ​​for meanand cov, for example:

import numpy as np
from scipy.stats import multivariate_normal as mvnorm

x = np.random.rand(5)
mvnorm.pdf(x, mean=0, cov=1)

I get the following output:

array([ 0.35082878,  0.27012396,  0.26986049,  0.39887847,  0.36116341])

Using:

import numpy as np
from scipy.stats import multivariate_normal as mvnorm

x = np.random.rand(5)
mvnorm.pdf(x)

gives the same error:

TypeError: pdf() takes at least 4 arguments (2 given)
+3
source

All Articles