function [recovery_results, sigma_w2, thresholds] = All_Recovery(A, x, P_fa, noise_sigma) global trail_times method LASSO_lambda tau iter_max; sz = size(A); M = sz(1); N = sz(2); recovery_results = zeros(2, trail_times, N); sigma_w2 = zeros(2, trail_times, 1); thresholds = zeros(2, trail_times, 1); figure; for hypo = 2: -1: 1 % hypo-假设 hypo = 3 - hypo; h = waitbar(0, '正在仿真' + string(hypo-1) + '假设情况'); for T = 1:trail_times waitbar(T / trail_times, h); noise = get_noise(noise_sigma, M, 1); % y = Ax + n if hypo == 1 y_noise = noise; else y_noise = A * x + noise; end if method == "debiased_LASSO" [x_hat, sigma_w_2, threshold] = debiased_LASSO(A, y_noise, P_fa, noise_sigma^2, LASSO_lambda); sigma_w2(hypo, T) = sigma_w_2; thresholds(hypo, T) = threshold; elseif method == "debiased_LASSO_FISTA" [x_hat, sigma_w_2, threshold] = debiased_LASSO_FISTA(A, y_noise, P_fa, noise_sigma^2, LASSO_lambda); sigma_w2(hypo, T) = sigma_w_2; thresholds(hypo, T) = threshold; elseif method == "cVAMPro" [x_LASSO, x_hat_d] = cVAMPro(y_noise, A, LASSO_lambda, tau, 100); % x_LASSO = FISTA(y_noise, A, LASSO_lambda, 1e-5); sz = size(A); n = sz(2); gamma = sz(1) / sz(2); lambda = LASSO_lambda; % CROD求去偏 rho_active = sum(abs(x_LASSO) > 1e-3)/n; Q_hat = (gamma - rho_active)/(1 - rho_active); Rho = sum((abs(x_LASSO) > 1e-3).* (2 - lambda./(Q_hat*abs(x_LASSO) + lambda))) / 2 / n; diff = 1; while(diff > 1e-4) Rho_pre = Rho; Rho = sum((abs(x_LASSO) > 1e-3).* (2 - lambda./((gamma-Rho)/(1-Rho)*abs(x_LASSO) + lambda))) / 2 / n; diff = abs(Rho - Rho_pre); end Q_hat = (gamma-Rho)/(1-Rho); x_d_CROD = x_LASSO + A'*(y_noise - A*x_LASSO)/Q_hat; % x_d_CROD == x_hat_d sigma_n = noise_sigma; % CROD求门限和检验统计量 RSS = sum(abs(y_noise - A * x_LASSO).^2)/length(y_noise); chi = Rho*(1 - Rho)/(gamma - Rho); if chi ~= 0 chi_temp = sqrt((chi+1)*(chi+1)-4*gamma*chi); z = -(1 - chi + chi_temp) / (2*chi); z_prime = -(1 - 2*gamma*chi + chi + chi_temp) / (2*chi*chi*chi_temp); G_prime = (z + 1/chi); G_wprime = (z_prime + 1/chi/chi); chi_hat = gamma/2*G_wprime*RSS/(G_prime - chi*G_wprime)... + (G_prime*G_prime/2 - gamma/2*G_wprime)*sigma_n*sigma_n/(G_prime - chi*G_wprime); else G_prime = gamma; G_wprime = gamma*(1-gamma); chi_hat = gamma/2*G_wprime*RSS/(G_prime - chi*G_wprime)... + (G_prime*G_prime/2 - gamma/2*G_wprime)*sigma_n*sigma_n/(G_prime - chi*G_wprime); end sigma_CROD = sqrt(2*chi_hat) / Q_hat; sigma_w2(hypo, T) = sigma_CROD^2; thresholds(hypo, T) = -sigma_CROD^2 * log(P_fa); % figure; subplot(221); plot(real(x)); subplot(222); plot(real(x_LASSO)); subplot(223); plot(real(x_hat_d)); subplot(224); plot(real(x_d_CROD)); if hypo == 2 x_hat = x_hat_d; % pp = real(x_hat - x); % [is_not_norm, tmp, tmp] = swtest(pp, 0.1); % % if is_not_norm % subplot(211); plot(pp); subplot(212); histfit(pp); % is_not_norm % end else x_hat = x_d_CROD; end else x_hat = recovery(A, y_noise, method); end recovery_results(hypo, T, :) = x_hat; end close(h); end end