Add basic code

This commit is contained in:
Ksyer
2024-07-16 15:54:44 +08:00
parent 088f1a82fd
commit e98983b374
5 changed files with 65 additions and 43 deletions
+31
View File
@@ -0,0 +1,31 @@
function [x_hat, threshold] = debiased_LASSO(A, y_noise, P_fa, noise_sigma_2)
sz = size(A);
N = sz(2);
LASSO_lambda = 2;
gamma = sz(1) / sz(2);
cvx_begin quiet
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;
diff = 1;
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;
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_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;
threshold = -sigma_w_2 * log(P_fa);
end