Solution (source code)

= Solution
{c}

For unknown normalization constants, use <self-normalized importance sampling> with $\tilde w=\tilde p/\tilde q$:
$$
\boxed{\tilde\mu_N=
\frac{\sum_i\tilde w(X_i)f(X_i)}{\sum_i\tilde w(X_i)}.}
$$
Under the same support condition, $E_q\tilde w=Z_p/Z_q>0$ and $E_q[\tilde w f]=(Z_p/Z_q)\mu$. Moreover $E_q|\tilde w f|=(Z_p/Z_q)E_p|f|<\infty$, by <Cauchy-Schwarz inequality> and the supplied $E_pf^2<\infty$. The <strong law of large numbers> applies to numerator and denominator sample averages. Their ratio tends almost surely, hence in probability, to $\mu$. If a finite sample happens to give zero denominator, it can be assigned an arbitrary value; this does not affect the eventual almost sure limit. The ratio estimator is generally biased at finite $N$.