【发布时间】:2022-11-26 02:54:05
【问题描述】:
我正在使用一个函数来计算似然密度。
我正在运行两个 xs,它们是长度为 7 的向量。
def lhd(x0, x1, dt): #Define a function to calculate the likelihood density given two values.
d = len(x0) #Save the length of the inputs for the below pdf input.
print(d)
print(len(x1))
lh = multivariate_normal.pdf(x1, mean=(1-dt)*x0, cov=2*dt*np.identity(d)) #Take the pdf from a multivariate normal built from x0, given x1.
return lh #Return this pdf value.
这里的均值是一个长度为 7 的向量,协方差是一个 (7,7) 数组。
当我运行它时,出现错误
ValueError: Array 'mean' must be a vector of length 49.
但是查看pdf的公式我认为这是不正确的。知道这里出了什么问题吗?
【问题讨论】:
标签: python scipy scipy.stats