I have a basic question about importance sampling.
Suppose we want to estimate the integral $ \int_1^2 f(x) dx$ where $f(x)$ is a probability distribution. We can introduce another probability distribution $g(x)$, then $\int_1^2 f(x) dx = \int_1^2 \frac{f(x)}{g(x)} g(x) dx = E_{g}[f/g] \approx \frac{1}{N} \sum_{i=1}^N f/g(X_i)$ where $X_i$ are drawn from $g$
So my question is, if $g(x)$ is a normal distribution, and I need to sample $N$ points from it. What do I do with the points that are outside of the interval $[1, 2]$ ?
Should I do rejection sampling, throwing away the points that don't lie in $[1,2]$ and set $N$ to be the number of the remaining points ?
or should I extend $f/g$ to $[-\infty, \infty]$ to be 0 when $x \notin [1,2]$ ?
I get some accurate result when I do rejection sampling, but keep the $N$ as the number of both accepted and rejected samples. But I don't know how to justify this.
I just realized rejecting samples that are not in $[1,2]$ while keeping the $N$ is the total number of both rejected and accepted samples is the equivalent to extending $f/g$ to all of real number, $f/g = 0$ if $x \notin [1,2]$, since for any samples outside of the interval, $f/g$ will be $0$ but the $N$ is still the overall number of samples.