Add basic code

This commit is contained in:
Ksyer
2024-07-16 15:55:00 +08:00
parent e98983b374
commit 1c009370a5
6 changed files with 121 additions and 19 deletions
+22 -14
View File
@@ -1,7 +1,11 @@
function [x_hat, threshold] = debiased_LASSO(A, y_noise, P_fa, noise_sigma_2)
function [x_hat, sigma_w_2, threshold] = debiased_LASSO(A, y_noise, P_fa, noise_sigma_2, LASSO_lambda)
if nargin < 5
LASSO_lambda = 1e-1;
end
sz = size(A);
N = sz(2);
LASSO_lambda = 2;
gamma = sz(1) / sz(2);
@@ -9,23 +13,27 @@ function [x_hat, threshold] = debiased_LASSO(A, y_noise, P_fa, noise_sigma_2)
variable x_LASSO(N) complex
minimize(LASSO_lambda * norm(x_LASSO, 1) + norm(y_noise - A * x_LASSO, 2))
cvx_end
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 - LASSO_lambda./(Q_hat*abs(x_LASSO) + LASSO_lambda))) / 2 / N;
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 - LASSO_lambda ./ (Q_hat * abs(x_LASSO) + LASSO_lambda))) / 2 / N;
diff = 1;
while(diff > 1e-4)
while (diff > 1e-4)
Rho_pre = Rho;
Rho = sum((abs(x_LASSO) > 1e-3).* (2 - LASSO_lambda./((gamma-Rho)/(1-Rho)*abs(x_LASSO) + LASSO_lambda))) / 2 / N;
Rho = sum((abs(x_LASSO) > 1e-3) .* (2 - LASSO_lambda ./ ((gamma - Rho) / (1 - Rho) * abs(x_LASSO) + 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;
Q_hat = (gamma - Rho) / (1 - Rho);
x_d_CROD = x_LASSO + A' * (y_noise - A * x_LASSO) / Q_hat;
x_hat = x_d_CROD;
RSS = 1/sz(2) * norm(y_noise - A*x_LASSO, 2) ^ 2;
sigma_w_2 = (gamma * (1 - gamma)) / ((gamma - Rho)^2) * RSS + noise_sigma_2;
RSS = 1 / sz(1) * norm(y_noise - A * x_LASSO, 2) ^ 2;
sigma_w_2 = (gamma * (1 - gamma)) / ((gamma - Rho) ^ 2) * RSS + noise_sigma_2;
threshold = -sigma_w_2 * log(P_fa);
xx = x_LASSO;
FAR_M = 1 / gamma;
xx(FAR_M+1: 2*FAR_M) = xx(FAR_M+1: 2*FAR_M) - 1;
xx = real(xx);
end