scipy.stats.gaussian_kde上的文档说该关键字bw_method
应该用于尝试不同的方法,但是当我尝试使用它时出现错误:
TypeError: __init__() got an unexpected keyword argument 'bw_method'
我正在运行的版本0.9.0
,Scipy
这里是MWE
:
import numpy as np
from scipy import stats
import scipy
print scipy.__version__
## Generate some random two-dimensional data:
def measure(n):
m1 = np.random.normal(size=n)
m2 = np.random.normal(scale=0.5, size=n)
return m1+m2, m1-m2
m1, m2 = measure(2000)
xmin = m1.min()
xmax = m1.max()
ymin = m2.min()
ymax = m2.max()
# Perform a kernel density estimate on the data:
x, y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j]
positions = np.vstack([x.ravel(), y.ravel()])
values = np.vstack([m1, m2])
kernel = stats.gaussian_kde(values, bw_method='silverman')