# Kernel Density Estimation

In the Kernel density estimation formula below (from Wikipedia), what do the values of $x$ and $x_i$ represent?

$$\hat f_h(x) = \frac{1}{n}\sum_{i=1}^n K_h(x-x_i) = \frac{1}{nh}\sum_{i=1}^n K\bigg(\frac{x-x_i}{h}\bigg)$$

I am implementing this formula but I am not sure about what they really represent. I know what values use for $x_i$, but I don't know what I'm passing in for $x$.

• Can you list the formula you are using? Sep 18 '15 at 16:42
• $x_i$ is a data value and the function is being evaluated at $x$. Sep 19 '15 at 0:33
• The formula is in this link: en.wikipedia.org/wiki/Kernel_density_estimation. I know what to use for xi, but i don't know what passing in x Sep 19 '15 at 7:38
• Typically, $x$ would be one of a grid of points on a range that at least covers that of your data set. Sep 19 '15 at 12:03
• But if, for example, my xi are: 2, 4, 6, 8... etc what is my correspondinf x value? Sep 19 '15 at 20:52

$x$ is the argument you're evaluating (calculating) the function (the density estimate) at.
$x_i$ the value of the $i$-th data point.
To draw the density, you'd normally evaluate $x$ across some reasonably fine grid of values.
But if, for example, my $x_i$ are: 2, 4, 6, 8... etc what is my corresponding x value?
$x$ will be whatever value you want to know $\hat{f}(x)$ at. This is like any other function -- If I said "here's a parabola, $g(x) = 3x^2-8x+5$" you're basically asking "but what value is $x$?". The answer is whatever value(s) you want to know $g$ at.