Solution (source code)

= Solution

Let $p(m)=P(m\mid\mathbf d)$ and draw independently from an importance density $q$. The unbiased estimator
$$
\widehat I=\frac1n\sum_{j=1}^n\frac{m_jp(m_j)}{q(m_j)}
$$
of $I=\int mp(m)\,dm$ has one-sample second moment
$$
\int\frac{m^2p(m)^2}{q(m)}\,dm.
$$
By the <Cauchy-Schwarz inequality>,
$$
\left(\int |m|p(m)\,dm\right)^2
\leq
\left(\int\frac{m^2p(m)^2}{q(m)}\,dm\right)
\left(\int q(m)\,dm\right).
$$
Equality holds precisely when $q(m)\propto|m|p(m)$, giving the <optimal importance density for a single integral>
$$
\boxed{q^*(m)=\frac{|m|p(m)}{\int|u|p(u)\,du}.}
$$
This is circular in practice: constructing and normalizing $q^*$ requires detailed knowledge of the posterior and the expectation of $|m|$. Here log masses are positive, so the unknown normalizer is the posterior mean being estimated. It is also optimal only for this one integral, not for general posterior summaries.