function AOC(a,Co_z,k,SNR,z)
% Perform number of N trials
N=500;
Sum_0=N;
Sum_1=N;
c1=1;

%Generate two hypotheses of z measurements, where they only differ in their
% mean
m=length(z);
mu=zeros(m,1);
invCo_z=inv(Co_z);
z_1= mvnrnd(a,Co_z,N)';
z_0= mvnrnd(mu,Co_z,N)';

%vary the threshold for ROC plot
Tau=[-4:0.1:2];

for tau=Tau(1):.1:Tau(end)
    TP1=0; FP1=0; %initial True positive and false positive
    for i=1:N
        % Testting H0
        GL0=a'* invCo_z*a - 2*z_0(:,i)' * invCo_z *a;
        if GL0 < tau
            FP1=FP1+1;
        end
        % Testing H1
        GL1=a'* invCo_z*a - 2*z_1(:,i)' * invCo_z *a;
        if GL1 < tau
            TP1=TP1+1;
        end
    end
    
    TPR1(c1,1)=TP1/Sum_1;
    FPR1(c1,1)=FP1/Sum_0;
    c1 =c1+1;
end

figure
plot(FPR1,TPR1,'LineWidth',1.5);
grid on
ks=num2str(k); SNRs=num2str(SNR);
title(['ROC Performance of GLRT for ' ks ' sparsity case, SNR=' SNRs])
xlabel('False Alarm'); ylabel(' Probability of Detection' );
ylim([0 1]);
end
