Solution (source code)

= Solution

For <independent> draws $X_i$ from a normalized proposal $g$, use the <importance sampling> identity
$$
\mu=\int\theta(x)f(x)\,dx
=\mathbb E_g\!\left[\theta(X)\frac{f(X)}{g(X)}\right].
$$
Thus the <unbiased estimator> and its <variance> are
$$
\boxed{\widehat\mu=\frac1n\sum_{i=1}^n\theta(X_i)\frac{f(X_i)}{g(X_i)},\qquad
\operatorname{Var}(\widehat\mu)=\frac1n\left[\int\frac{\theta(x)^2f(x)^2}{g(x)}\,dx-\mu^2\right].}
$$
The <probability support> condition is $g>0$ wherever $\theta f\ne0$, and the <variance> formula requires a finite <second moment>. Since both <probability densities> are normalized, no self-normalization of weights is needed.

In the proposed example, normalize $g$ to $g(x)=3x^2$ on $(0,1)$. It is sampled by $X=U^{1/3}$ for uniform $U$. Taking $\theta(x)=x$ gives
$$
\boxed{\widehat\mu_g=\frac1n\sum_{i=1}^n\frac4{3\pi}\frac{\sqrt{1-X_i^2}}{X_i},
\qquad X_i\sim3x^2\mathbf1_{(0,1)}(x).}
$$
As a check, $\mu_g=\frac4\pi\int_0^1x\sqrt{1-x^2}\,dx=4/(3\pi)$. The <second moment> of one weighted observation is
$$
\int_0^1\frac{x^2f(x)^2}{3x^2}\,dx
=\frac{16}{3\pi^2}\int_0^1(1-x^2)\,dx
=\frac{32}{9\pi^2},
$$
so $\operatorname{Var}(\widehat\mu_g)=16/(9\pi^2n)$. The weight's singularity at zero does not make this <variance> infinite.

To prove the optimal proposal rule, apply the <Cauchy-Schwarz inequality>:
$$
\left(\int|\theta(x)|f(x)\,dx\right)^2
=\left(\int\frac{|\theta(x)|f(x)}{\sqrt{g(x)}}\sqrt{g(x)}\,dx\right)^2
\leq\int\frac{\theta(x)^2f(x)^2}{g(x)}\,dx.
$$
Equality holds when the two factors are proportional almost everywhere, giving the <minimum-variance importance distribution>
$$
\boxed{g_0(x)=\frac{|\theta(x)|f(x)}{\int|\theta(u)|f(u)\,du}.}
$$
For the present nonnegative integrand, normalization gives
$$
\boxed{g_0(x)=3x\sqrt{1-x^2}\quad(0<x<1).}
$$
Under this proposal, $xf(x)/g_0(x)=4/(3\pi)$ is constant, so the <variance> is exactly zero. If sampling is wanted, its distribution function is $1-(1-x^2)^{3/2}$, with inverse $X=\sqrt{1-(1-U)^{2/3}}$. In general the optimal proposal's <normalizing constant> can itself be the unknown integral, limiting this zero-variance construction's practical use.