density approximation using monte carlo

61 Views Asked by At

I am confused about how i can approximate a probability density function using Monte Carlo simulation.
If we let $X_{1:n}$ be $n$ simulations of a density $p$, then it is said that $$ p(x) \approx \hat{p}(x) = \frac{1}{n} \sum_{i=1}^n \delta_{X_i}(x)$$ There comes the confusion: what is $\delta_{x_0}(x).$ is it $\mathbb{1}_{x_0}(x)$ or does it put infinite mass on $x_0$ and zeroes everywhere else?
I'm confused about it because i know that if i want to approximate the expectation of $X$, i do the following $$ \int xp(x)dx \approx \int x\hat{p}(x)dx = \frac{1}{n} \sum_{i=1}^n \int x\delta_{X_i}(x)dx = \frac{1}{n} \sum_{i=1}^n X_i$$ but then for this to be true, $\delta$ would have to put infinite mass on each $X_i$. On the other hand, if i want to plot the approximation of $p(x)$, i would use $\mathbb{1}_{X_i}$ but it doesn't seem to be consistent with the Monte Carlo for expectation estimation.

Thank you