I have some troble understanding the Kernel density estimation.
If a consider the next example:
s<-0 z<-density(rnorm(25)) f<-function(i)approx(z$x,z$y,xout=i)$y for(i in seq(min(z$x),max(z$x),length.out = 10000)) s<-s+f(i) s
I expected getting that s is approximately equals to one since I am considering an approximation for the integral of the Kernel density function (that I suppose is also a density). However, I don't get the expected result. Why it doesn's sum one? The idea behind this is that I wanted to use the Kernel as the density of my data points. I was interpolating to get my explicit function and use with other x values. Or do you know another way to get a density function estimated by fitting?