Density comparison I am trying to compare two densitys, namely ${f}_{t}(\bullet)$ and ${g}_{t}(\bullet)$. I have simulated returns for both distributions, roughly 10,000 of them. I now need to compare the the probability of observing an observation $y_{t,s}$ in each of the distributions to compute the following value:
\begin{equation*}
d_{t,s} = \text{ln}\widehat{f}_{t}(y_{t,s}) - \text{ln}\,\widehat{g}_{t}(y_{t,s} ).
\end{equation*}
My problem is that I am not sure how to compute the probability ${f}_{t}(y_{t,s})$ from my sample. Should I pick all values with a small error arround $y_{t,s}$ or find exactly $y_{t,s}$ in the sample? 
 A: I would suggest that you calculate a kernel density estimate of your samples $f$ and $g$ and evaluate these densities at the $y$ you are interested in.
An example with dummy data in R:
set.seed(1)
ff <- rnorm(1e4,0,1)
gg <- rnorm(1e4,0.3,0.7)
yy <- 1

ff.density <- density(ff)
gg.density <- density(gg)
ff.fun <-  function(x) ff.density$y[which.min(abs(ff.density$x - x))]
gg.fun <-  function(x) gg.density$y[which.min(abs(gg.density$x - x))]

plot(ff.density,xlab="",ylab="",main="",ylim=range(ff.density$y,gg.density$y))
lines(gg.density,col="red")
abline(v=yy,lty=2)
legend("topleft",lwd=1,col=c("black","red","black"),lty=c(1,1,2),legend=c("f","g","y"))

log(ff.fun(yy))-log(gg.fun(yy))
# [1] -0.2947274


Here are two ways of evaluating such densities in R. Look at ?density for a few parameters you can use to tune the density estimate, e.g., the bandwidth.

If performance is an issue as you write in a comment, I would suggest that you simply count how many samples fall "near" the point at which you want to evaluate the density (which you wouldn't estimate "overall"). You would still need to experiment a bit with how "near" you want the samples to be (e.g., 1/100 the entire range of your samples, or of the difference between the 5% and 95% quantiles, to reduce the impact of outliers).
As a matter of fact, this is almost a kernel density estimate, evaluated at your $y$ of interest, using a rectangular kernel. And it should be reasonably fast, too. If your "bandwidth" is fixed, you can walk through the arrays once - you don't even need to sort them.
