0
$\begingroup$

The routine explanation of a KDE plot is:

  1. You chose a kernel (let's say a Gaussian)
  2. You center a kernel at each data point
  3. You average all kernels

I get that (2) means that a Gaussian curve is "plotted" so that the mean of that individual Gaussian distribution is the data point.

But how do you come up with the standard deviation for that individual Gaussian kernel? The explanations I found so far seem to gloss over this point.

I initially assumed that the standard deviation is the one computed from the sample but I saw some explanations that seem to contradict it. In particular I mean the example given in the Wikipedia article on "KDE". There they give the example of a sample:

np.array([-2.1, -1.3, -0.4, 1.9, 5.1, 6.2])

and place on each data point a Gaussian kernel with variance 2.25. However, the variance of that sample is 9.932.

So how do they come up with this value for the variance?

I wish I could find a single worked example (preferably with python code) that makes each step explicit rather than hiding it behind an API so that I can understand this.

EDIT:

I am asking about the standard deviation of the individual kernel (in the case of a Gaussian kernel), not about the band-width. Not sure why I am pointed to questions discussing the band-width.

$\endgroup$
4
  • 1
    $\begingroup$ David Scott's Multivariate Density Estimation: Theory, Practice, and Visualization has many suggestions if you search for standard deviation. google.com/books/edition/Multivariate_Density_Estimation/… $\endgroup$
    – user78229
    Commented Jul 14, 2023 at 10:51
  • $\begingroup$ Check the linked threads. You can also search the site for more question like this stats.stackexchange.com/search?q=bandwidth+selection+kernel $\endgroup$
    – Tim
    Commented Jul 14, 2023 at 11:32
  • $\begingroup$ @Tim I am getting confused - why do you refer to questions discussing the band-width? I am asking about the standard deviation of the individual kernel in the case of a Gaussian kernel. $\endgroup$
    – Nick
    Commented Jul 14, 2023 at 12:45
  • 2
    $\begingroup$ Because the standard deviation is the bandwidth. $\endgroup$
    – Tim
    Commented Jul 14, 2023 at 12:46

0

Browse other questions tagged or ask your own question.