2

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$.

amoeba
  • 104,745

1 Answers1

3

Since this doesn't have an answer yet, I'll expand my comment a little:

$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.

Glen_b
  • 282,281