In Introducing Monte Carlo Methods, by Robert and Casella, we have
How do we derive the second equality? Shouldn't it be
$$E\left[\frac{f(X_i)}{g_{Y_i}(X_i)}|X_i\right]=\frac{f(X_i)}{g_1(X_i)}\rho+\frac{f(X_i)}{g_2(X_i)}(1-\rho)$$
In Introducing Monte Carlo Methods, by Robert and Casella, we have
How do we derive the second equality? Shouldn't it be
$$E\left[\frac{f(X_i)}{g_{Y_i}(X_i)}|X_i\right]=\frac{f(X_i)}{g_1(X_i)}\rho+\frac{f(X_i)}{g_2(X_i)}(1-\rho)$$
Yeah that’s what I thought when I first looked at it. But the conditional expectation is taken with respect to the conditional pmf of $Y$ given $X_i =x_i$. If $y=1$ the weight for $f(x_i) g_1^{-1}(x_i)$ is $\frac{\varrho g_1(x_i)}{g_1(x_i)\varrho + g_2(x_i) (1-\varrho)}$. You can follow a similar path to obtain the weight for $f(x_i) g_2^{-1}(x_i)$, then you add the two weighted values together, and then there’s some cancellation, and it ends up being what the book says.
Hopefully a correct derivation based on Taylor's answer...
$$E\left[\frac{f(X_i)}{g_{Y_i}(X_i)}|X_i\right]=\int \frac{f(X_i)}{g_{Y_i}(X_i)}k(X_i,dY_i)=\sum_{j=1}^2 \frac{f(X_i)}{g_j(X_i)}\frac{p(X_i|Y_{i}=j)p(Y_{i}=j)}{p(X_i)}$$
where $k$ is a regular conditional distribution, $X_i$ is cont. and $Y_i$ is discrete,
$$\sum_{j=1}^2 \frac{f(X_i)}{g_j(X_i)}\frac{p(X_i|Y_{i}=j)p(Y_{i}=j)}{p(X_i)}=\frac{f(X_i)}{g_1(X_i)}\frac{g_1(X_i)\varrho}{g_1(X_i)\varrho+g_2(X_i)(1-\varrho)}+\frac{f(X_i)}{g_2(X_i)}\frac{g_2(X_i)(1-\varrho)}{g_1(X_i)\varrho+g_2(X_i)(1-\varrho)} = \frac{f(X_i)}{g_1(X_i)\varrho+g_2(X_i)(1-\varrho)}$$
Just to step in a wee bit late, \begin{align*} \mathbb{E}\left[\dfrac{f(X_i)}{g_{Y_i}(X_i)}\big|X_i\right] &= \dfrac{f(X_i)}{g_{1}(X_i)} \mathbb{P}(Y_i=1|X_i) + \dfrac{f(X_i)}{g_{2}(X_i)} \mathbb{P}(Y_i=2|X_i)\\ &= \dfrac{f(X_i)}{g_{1}(X_i)} \dfrac{\rho g_1(X_i)}{\rho g_1(X_i) +(1-\rho) g_2(X_i)} + \dfrac{f(X_i)}{g_{2}(X_i)} \dfrac{(1-\rho) g_2(X_i)}{\rho g_1(X_i) +(1-\rho) g_2(X_i)}\\ &= \dfrac{f(X_i)}{1} \dfrac{\rho {1}}{\rho g_1(X_i) +(1-\rho) g_2(X_i) } + \dfrac{f(X_i)}{1} \dfrac{(1-\rho) 1}{\rho g_1(X_i)+(1-\rho) g_2(X_i)}\\ &= \dfrac{f(X_i)}{\rho g_1(X_i)+(1-\rho) g_2(X_i)}\\ \end{align*}