Reputation: 2134
Trying to evaluate scipy's multivariate_normal.pdf
function, 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)
The docs say both the mean
and cov
arguments are optional, and that the last axis of x
labels the components. Since x.shape
= (4L,)
, it seems like all is kosher. I am expecting a single number as output.
Upvotes: 4
Views: 6452
Reputation: 5157
It looks like these parameters aren't optional.
If I pass the default values for mean
and cov
like:
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])
While using:
import numpy as np
from scipy.stats import multivariate_normal as mvnorm
x = np.random.rand(5)
mvnorm.pdf(x)
gives me the same error:
TypeError: pdf() takes at least 4 arguments (2 given)
Upvotes: 3