# A Two-Stage Method to Test the Robustness of the Generalized Approximate Message Passing Algorithm
## 2 GAMP Algorithm Review
The steps of GAMP are listed in Algorithm 1, where \(|\mathbf{A}|^{2}\) is a componentwise magnitude squared, the elementwise product and division are denoted as \(\odot\) and \(\oslash\), respectively, notation \([\cdot]\) means the componentwise form of a vector, e.g., \(\mathbf{a}=[a_{i}]\), and notation \(|\cdot|\) means the cardinality of a set, or the number of non-zero elements of a sparse vector. When the prior is a Bernoulli-Gaussian distribution [7]  
\[p_{\kappa_{n}}(x)=(1-\lambda)\delta(x)+\lambda\mathcal{N}(x;\theta,\phi), \tag{8}\]  
where \(\lambda\) is the sparsity-rate \(K/N\), and the mean \(\theta\) and variance \(\phi\) are hyper-parameters which are set to zero and one respectively at the initiation and those parameters do not change in the algorithm running time. It is called BG-GAMP algorithm. One can obtain the input channel marginal posterior  
\[p_{\kappa_{n}|\tau_{n}}(x|\hat{\tau}_{n},\
u^{r}_{n}) =\Big{(}(1-\lambda)\delta(x_{n})+\lambda\mathcal{N}(x_{n};\theta, \phi)\Big{)}\frac{\mathcal{N}(x_{n};\hat{\tau}_{n},\
u^{r}_{n})}{\zeta_{n}} \tag{9}\] \[=(1-\pi_{n})\delta(x_{n})+\pi_{n}\mathcal{N}(x_{n};\gamma_{n},\mu _{n}) \tag{10}\]  
with the normalization factor  
\[\zeta_{n}\triangleq\int p_{\kappa_{n}}(x)\mathcal{N}(x;\hat{\tau}_{n},\
u^{r} _{n})\mathrm{d}x=(1-\lambda)\mathcal{N}(0;\hat{\tau}_{n},\
u^{r}_{n})+\lambda \mathcal{N}(0;\hat{\tau}_{n}-\theta,\
u^{r}_{n}+\phi) \tag{11}\]  
and \((\hat{\tau}_{n},\
u^{r}_{n},\lambda,\theta,\phi)\)-dependent variables  
\[\mathbb{E}\{z_{m}|\mathbf{p}_{m}=\hat{p}_{m},v_{m}^{p}\} =\int z_{m}\;p_{z_{m}|\mathbf{p}_{m}}(z_{m}|\hat{p}_{m},v_{m}^{p}) \mathrm{d}z_{m} \tag{3}\]0 \[\mathbb{E}\{z_{m}|\mathbf{p}_{m}=\hat{p}_{m},v_{m}^{p}\} =\int z_{m}\;p_{z_{m}|\mathbf{p}_{m}}(z_{m}|\hat{p}_{m},v_{m}^{p}) \mathrm{d}z_{m} \tag{3}\]1 (13) \[\mathbb{E}\{z_{m}|\mathbf{p}_{m}=\hat{p}_{m},v_{m}^{p}\} =\int z_{m}\;p_{z_{m}|\mathbf{p}_{m}}(z_{m}|\hat{p}_{m},v_{m}^{p}) \mathrm{d}z_{m} \tag{3}\]2  
where \(\pi_{n}\) is the input channel marginal posterior support probability \(\Pr\{\chi_{n}\
eq 0|\hat{\tau}_{n},\
u^{r}_{n}\}\), according to Equation (10), and then \(\Pr\{\chi_{n}=0|\hat{\tau}_{n},\
u^{r}_{n}\}=1-\pi_{n}\). Substituting Equation (10) to Equations (6) and (7), we have  
\[\mathbb{E}\{z_{m}|\mathbf{p}_{m}=\hat{p}_{m},v_{m}^{p}\} =\int z_{m}\;p_{z_{m}|\mathbf{p}_{m}}(z_{m}|\hat{p}_{m},v_{m}^{p}) \mathrm{d}z_{m} \tag{3}\]3 \[\mathbb{E}\{z_{m}|\mathbf{p}_{m}=\hat{p}_{m},v_{m}^{p}\} =\int z_{m}\;p_{z_{m}|\mathbf{p}_{m}}(z_{m}|\hat{p}_{m},v_{m}^{p}) \mathrm{d}z_{m} \tag{3}\]4  
The hypothesis of Bernoulli-Gaussian data \(\mathbf{x}\) is sparse. Sparsity-rate \(\lambda\) has been set to \(K/N\). Although the sparsity \(K\) is unknown in practice, we can choose a small \(K\) value and an error bound,and then we do the recovery algorithm. If the recovery result makes the final reconstruction error lower than the bound, this result can be accepted, otherwise we decrease the \(K\) value and do the recovery again until the bound has been achieved. This procedure is like the Least Angle Regression (LARS) algorithm which tests all the regularization hyper-parameters.