Suppose we are interested in the expectation of a test function $f(X)$ with respect to target distribution $\pi(X) \propto \gamma(X)$ using importance sampling with proposal distribution $q(X)$ with $M$ samples. Suppose we only know $\gamma$ and not $\pi$. Let $w(X) = \frac{\gamma(X)}{q(X)}$. Then we have
$$F = \mathbb{E}_{\pi}[f(X)] = \frac{\mathbb{E}_q[f(X)w(X)]}{\mathbb{E}_q[w(X)]} \approx \frac{\sum_{i=1}^M f(X_i)w(X_i)}{\sum_{j=1}^M w(X_j)} = \hat F.$$
How do I derive the bias of $\hat F$?
(below is one of my many attempts in finding a nice form for the expected value of $\hat F$) $$\mathbb{E}_q \Big[\frac{\sum_i^M f(X_i)w(X_i)}{\sum_j^M w(X_j)}\Big] = M \mathbb{E}_q \Big[ \frac{f(X_1)w(X_1)}{\sum_j w(X_j)}\Big] = M \int \frac{f(x_1)\gamma(x_1)}{\sum_{j=1}^M w(x_j)}\prod_{i=2}^M[ q(x_i) dx_i] $$