I'm using the scipy.stats.gaussian_kde function to generate a KDE from a set of $N$ points in a 2D space: $A = \{(x_1,y_1), (x_2,y_2), (x_3,y_2), ..., (x_N,y_N)\}$

Each one of these points has a given error attached to it. So for example, the point $(x_1,y_1)$ has errors $(e_{x_1},e_{y_1})$ and so on. I can assume the errors are normally distributed in both axis.

The python function that I use to generate the KDE has no way to integrate these errors into the calculations and I wonder how I would even do such a thing if I did it manually.

Ie: what is the statistically correct way to generate a KDE accounting for errors in the data used?

  • $\begingroup$ Did you find a solution to you problem? I now have a similar case, but with 1D data instead 2D. I have an error associated with each value and would like to generate a new array with these errors $\endgroup$
    – Srivatsan
    Commented Mar 11, 2015 at 10:34
  • $\begingroup$ @ThePredator see this question: stackoverflow.com/questions/28330959/… $\endgroup$
    – Gabriel
    Commented Mar 11, 2015 at 11:55
  • $\begingroup$ @ThePredator You're welcome :) And if you come up with some way to improve the answer in that question, please share it over there. Cheers! $\endgroup$
    – Gabriel
    Commented Mar 11, 2015 at 13:33

1 Answer 1


You will need a robust loss function in the kernel estimation model. However, this topic may become quite advances very fast. :) For a good start, I would suggest the one class SVM from sklearn. http://scikit-learn.org/stable/modules/svm.html#density-estimation-novelty-detection

  • $\begingroup$ No idea how I should apply such a method to my issue, sorry. Upvote for pointing me to scikit-learn, I hadn't heard about that package, thanks. $\endgroup$
    – Gabriel
    Commented Oct 15, 2013 at 10:57
  • $\begingroup$ Well, here is an example: scikit-learn.org/stable/auto_examples/svm/… $\endgroup$
    – mojovski
    Commented Oct 15, 2013 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.