from KDEpy import FFTKDE
data = np.random.randn(2**6)  # Normal distribution
weights = data**2  # Large weights away from zero

x, y = FFTKDE(bw='silverman').fit(data, weights).evaluate()
plt.plot(x, y, label=r'Weighted away from zero $w_i = x_i^2$')

y2 = FFTKDE(bw='silverman').fit(data).evaluate(x)
plt.plot(x, y2, label=r'Unweighted $w_i = 1/N$')

plt.title('Weighted and unweighted KDE')
plt.tight_layout(); plt.legend(loc='best');