[SciPy-User] typo in stats tutorial?

Neal Becker ndbecker2@gmail....
Wed Dec 5 13:01:44 CST 2012


The text says there's very little difference between Scott's Rule and 
Silverman's Rule.  With the code, I don't think there'd be any difference at 
all:

from scipy import stats

x1 = np.array([-7, -5, 1, 4, 5], dtype=np.float)
kde1 = stats.gaussian_kde(x1)
kde2 = stats.gaussian_kde(x1, bw_method='silverman')

fig = plt.figure()
ax = fig.add_subplot(111)

ax.plot(x1, np.zeros(x1.shape), 'b+', ms=20)  # rug plot
x_eval = np.linspace(-10, 10, num=200)
ax.plot(x_eval, kde1(x_eval), 'k-', label="Scott's Rule")
ax.plot(x_eval, kde1(x_eval), 'r-', label="Silverman's Rule")

plt.show()



More information about the SciPy-User mailing list