# Adaptive (variable) bandwidth in 2D Gaussian kernel density estimator to account for measurement errors

I have a 2D dataset composed of $N$ measured values for two discrete variables, $(x_i,y_i), i=1..N$, with associated standard deviations for each point $(\sigma_{ix}, \sigma_{iy}), i=1..N$.

I want to apply a 2D kernel density estimator to this dataset, accounting for the errors in each $(x_i,y_i)$ pair.

I thought of extending the method mentioned here for 1D: Kernel density estimation incorporating uncertainties, i.e.: the information given by the standard deviations are introduced into the Gaussian kernel as the bandwidth values.

This is the mathematical form of my adaptive 2D Gaussian kernel estimator using the standard deviations $(\sigma_{ix}, \sigma_{iy})$ of each measured point $(x_i,y_i)$ as the bandwidths:

$$KDE_{2D}(x,y) = \frac{1}{2\pi N} \sum_{i=1}^N \frac{1}{\sigma_{ix}\sigma_{iy}} e^{-\frac{1}{2}\left(\frac{(x-x_i)^2}{\sigma_{ix}^2}+\frac{(y-y_i)^2}{\sigma_{iy}^2}\right)}$$

Is this reasonable from a statistical point of view? Are there any caveats I should aware of?

The article Local bandwidth selectors for deconvolution kernel density estimation mentioned in this answer seems to address this issue, but the level of statistics handled there is way beyond my level.

Some years ago I had asked if there was an implementation for the procedure described above: Adding errors to Gaussian kernel density estimator. As I never really got an answer, I wrote one myself, based on the kernel presented here.