title: Python fast Kernel Density estimation (probability density function)
body: <p>I'm looking for a way to get the kernel density function of a data set and plot it for arbitrary data points. Using Scipy stats module, I came up with the following code:</p>
  
  <pre><code>import numpy as np
  import scipy.stats as st
  
  def get_pdf(data):
      a = np.array(data)
      ag = st.gaussian_kde(a)
      x = np.linspace(0, max(data), max(data)*10)
      y = ag(x)
      return x, y
  </code></pre>
  
  <p>This gives the expected result, but the performance is very poor, when the data set size is large. </p>
  
  <p>I found <a href="https://pypi.org/project/fastkde/" rel="nofollow noreferrer"><code>fastkde</code></a> as an implementation for fast kernel density estimation. But I could not figure out a way to use this in the same way I used Scipy stats KDE. </p>
  
  <p>Can someone give me some insight?</p>
  
  <p>Thanks</p>