typo in stats tutorial?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

typo in stats tutorial?

Neal Becker
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()

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: typo in stats tutorial?

josef.pktd
On Wed, Dec 5, 2012 at 2:01 PM, Neal Becker <[hidden email]> wrote:

> 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")

kde2

what are we supposed to see?

nice, example runs without changes in python 3.2.3 (the only python on
my computer that seems to have a recent scipy and matplotlib)

Josef

>
> plt.show()
>
> _______________________________________________
> SciPy-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user