$$f_{v_n}(\Delta_v,\q_n)\!=\!-[f_{a_n}(\Delta_v,\q_n)]^2+\frac{\rho}{C(\Delta_v+1)}\!\l[\frac{\q_n^2}{\Delta_v+1}\!+\!\Delta_v\r],$$ where $\q_n^2=\l[\l(q_n^{(1)}\r)^2,\ldots,\l(q_n^{(J)}\r)^2\r]$ and $$C=\rho+(1-\rho)\l(1+\frac{1}{\Delta_v}\r)^{\frac{J}{2}}\exp\l[-\frac{\q_n\q_n^T}{2\Delta_v(\Delta_v+1)}\r].$$ Notice that in Line \[line:scalarNoiseVar\] we take the mean of a vector to obtain a scalar $\Delta_v^{(j)}$, which is the average of the variances for the estimates of signal entries $x_n^{(j)}$. This is because the super-symbols $\x_n, \forall n$, of the signals are i.i.d and the $J$ measurement channels are i.i.d. For the same reason, $\Delta_v^{(j)},\ j\in\{1,\ldots,J\}$, should be close to each other; hence, Line \[line:mean\_delta\]. Note that Algorithm \[algo:AMP\_MMV\] assumes that the entries of $\A^{(j)}$ scale with $\frac{1}{\sqrt{N}}$, and is a more generic form of an algorithm from our prior work with Krzakala [@ZhuBaronKrzakala2017IEEE].

[**Metric-optimal denoiser:**]{} The second part of our metric-optimal algorithm takes as inputs the noisy pseudo data $\q_n=\x_n+\v_n$ and the estimated variance of $\v_n,\ \Delta_v$, from the MP algorithm. Using Bayes’ rule, we can derive the posterior $f(\x_n|\q_n)$ and use $f(\x_n|\q_n)$ to formulate the optimal estimator in the sense of the user-defined error metric. The optimal estimate is $$\label{eq:estimator}
\widetilde{\x}_n=\arg\min_{\widehat{\x}_n} \int d_{\text{UD}}(\x_n,\widehat{\x}_n) f(\x_n|\q_n) d\x_n.
$$

Converse part: The optimal estimate {#sec:converse}
-----------------------------------

The reason why  is optimal is based on the insight from Rangan [@RanganGAMP2011ISIT] that in SMV the density function $f(x_n|q_n)$ converges to the posterior $f(x_n|\y)$. A rigorous proof for 