I am trying to use the package fastkde to estimate the density from a sample. The authors give an example
""" Demonstrate the first README example. """
import numpy as np
import fastkde
import matplotlib.pyplot as plt
#Generate two random variables dataset (representing 100,000 pairs of datapoints)
N = int(1e5)
x = 50*np.random.normal(size=N) + 0.1
y = 0.01*np.random.normal(size=N) - 300
#Do the self-consistent density estimate
PDF = fastkde.pdf(x, y, var_names = ['x', 'y'])
PDF.plot();
However, I don't know how to proceed in the case of a single random variable. In my case, I have a sample z containing 100,000 observations. I want to predict the density at each data point in w:
import numpy as np
import fastkde
N = int(1e5)
z = 50*np.random.normal(size=N) + 0.1
w = list(range(10,0,-2))
Could you elaborate on how to do so? Thank you so much for your elaboration!