clear all


w = 1; % class 1
mu1 = 10;
sigma1 = 1;

w = 2; % class 2
mu2 = 12;
sigma2 = 1;

num_samples = 1000;  % number of test samples from each class
delx = 0.1;


% test samples from class 1
x1 = mu1 + sigma1*randn(num_samples,1);  
% test samples from class 2
x2 = mu2 + sigma2*randn(num_samples,1);

Pd_save = [];
Pf_save = [];

% x_c is a classifier 
for x_c = 1:0.5:30

    % number of TP (True Positive) samples
    nTP = length(find(x2 > x_c));
    % approximate probability of hit, P(x > x_c | x in w=2)
    Pd = nTP / num_samples;

    % number of FP (False Positive) samples
    nFP = length(find(x1 > x_c));
    % approximate probability of false alarm, P(x > x_c | x in w=1)
    Pf = nFP / num_samples;

    Pd_save = [Pd_save; Pd];
    Pf_save = [Pf_save; Pf];
   
end

figure
hold on
plot(Pf_save, Pd_save, 'r:')




w = 1; % class 1
mu1 = 10;
sigma1 = 1;

w = 2; % class 2
mu2 = 12;
sigma2 = 4;

num_samples = 1000;  % number of test samples from each class
delx = 0.1;


% test samples from class 1
x1 = mu1 + sigma1*randn(num_samples,1);  
% test samples from class 2
x2 = mu2 + sigma2*randn(num_samples,1);

Pd_save = [];
Pf_save = [];

% x_c is a classifier 
for x_c = 1:0.5:30

    % number of TP (True Positive) samples
    nTP = length(find(x2 > x_c));
    % approximate probability of hit, P(x > x_c | x in w=2)
    Pd = nTP / num_samples;

    % number of FP (False Positive) samples
    nFP = length(find(x1 > x_c));
    % approximate probability of false alarm, P(x > x_c | x in w=1)
    Pf = nFP / num_samples;

    Pd_save = [Pd_save; Pd];
    Pf_save = [Pf_save; Pf];
   
end


plot(Pf_save, Pd_save, 'b:')




w = 1; % class 1
mu1 = 10;
sigma1 = 4;

w = 2; % class 2
mu2 = 12;
sigma2 = 1;

num_samples = 1000;  % number of test samples from each class
delx = 0.1;


% test samples from class 1
x1 = mu1 + sigma1*randn(num_samples,1);  
% test samples from class 2
x2 = mu2 + sigma2*randn(num_samples,1);

Pd_save = [];
Pf_save = [];

% x_c is a classifier 
for x_c = 1:0.5:30

    % number of TP (True Positive) samples
    nTP = length(find(x2 > x_c));
    % approximate probability of hit, P(x > x_c | x in w=2)
    Pd = nTP / num_samples;

    % number of FP (False Positive) samples
    nFP = length(find(x1 > x_c));
    % approximate probability of false alarm, P(x > x_c | x in w=1)
    Pf = nFP / num_samples;

    Pd_save = [Pd_save; Pd];
    Pf_save = [Pf_save; Pf];
   
end


plot(Pf_save, Pd_save, 'g:')



w = 1; % class 1
mu1 = 10;
sigma1 = 4;

w = 2; % class 2
mu2 = 12;
sigma2 = 4;

num_samples = 1000;  % number of test samples from each class
delx = 0.1;


% test samples from class 1
x1 = mu1 + sigma1*randn(num_samples,1);  
% test samples from class 2
x2 = mu2 + sigma2*randn(num_samples,1);

Pd_save = [];
Pf_save = [];

% x_c is a classifier 
for x_c = 1:0.5:30

    % number of TP (True Positive) samples
    nTP = length(find(x2 > x_c));
    % approximate probability of hit, P(x > x_c | x in w=2)
    Pd = nTP / num_samples;

    % number of FP (False Positive) samples
    nFP = length(find(x1 > x_c));
    % approximate probability of false alarm, P(x > x_c | x in w=1)
    Pf = nFP / num_samples;

    Pd_save = [Pd_save; Pd];
    Pf_save = [Pf_save; Pf];
   
end


plot(Pf_save, Pd_save, 'k:')

hold off