Solution (source code)

= Solution

Put $A=\int|\theta(x)|f(x)\,dx$, with $0<A<\infty$. The <Cauchy-Schwarz inequality> applied to $|\theta|f/\sqrt g$ and $\sqrt g$ gives
$$
A^2\leq\left(\int\frac{\theta^2f^2}{g}\right)\left(\int g\right)=\int\frac{\theta^2f^2}{g}.
$$
Equality holds exactly when $|\theta|f/\sqrt g$ is proportional to $\sqrt g$ on the contributing <probability support>. Therefore the <minimum-variance importance distribution> is
$$
\boxed{g_0(x)=\frac{|\theta(x)|f(x)}A,\qquad\min_g\operatorname{Var}(\widehat\mu_g)=\frac{A^2-\mu^2}{n}.}
$$
If $\theta$ has one sign, $A=|\mu|$ and the ideal proposal gives zero <variance>. Its normalization or exact sampling may nevertheless be impractical. If $A=0$, the integrand vanishes almost everywhere and the <estimator> is identically zero.

The minimizing <probability density function> may vanish where $\theta=0$ even though $f>0$ there. This is valid for the ordinary <estimator>, which needs <probability support> only for its integrand. If one insists on exactly the same positive <probability support> as $f$, the bound is instead an infimum whenever this vanishing occurs, approached by $g_\delta=(1-\delta)g_0+\delta f$ as $\delta\downarrow0$: because $g_\delta\geq(1-\delta)g_0$, the second moment lies between $A^2$ and $A^2/(1-\delta)$, proving convergence to the bound.