I'm using SciPy's stats.gaussian_kde function to generate a kernel density estimate (kde) function from a data set of x,y
points.
This is a simple MWE of my code:
import numpy as np
from scipy import stats
def random_data(N):
# Generate some random data.
return np.random.uniform(0., 10., N)
# Data lists.
x_data = random_data(100)
y_data = random_data(100)
# Obtain the gaussian kernel.
kernel = stats.gaussian_kde(np.vstack([x_data, y_data]))
Since I'm not setting a bandwidth manually (via the bw_method
key), the function defaults to using Scott's rule (see function's description). What I need is to obtain this bandwidth value set automatically by the stats.gaussian_kde
function.
I've tried using:
print kernel.set_bandwidth()
but it always returns None
instead of a float.