from scipy import stats import matplotlib.pyplot as plt 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, kde2(x_eval), 'r-', label="Silverman's Rule") plt.show()