close all
%% generate a single path
T = 10;
N = 100;
dt = T/N;

mu = 0.1;
sigma = 0.2;
r = 0.01;

[ Sp Sq ] = SimCRR(T, N, mu, sigma, r);


plot([0: dt : T], Sp, '-b', 'LineWidth',2);
hold on ;
plot([0: dt : T], Sq,'-r','LineWidth',1);
hold off;
legend('P', 'Q');


%% generate many paths
M = 5000;
SpT = zeros(M,1);
SqT = zeros(M,1);
for i = 1 : M
    
   [ Sp Sq ] = SimCRR(T, N, mu, sigma, r); 
   SpT(i) = Sp(end);
   SqT(i) = Sq(end);
   
end

clc;
figure
hist(SpT);
title('P');
display(['P-mean = ' num2str(mean(log(SpT)))]);
display(['P-std.dev= ' num2str(sqrt(var(log(SpT))))]);

figure
title('Q');
hist(SqT);
display(['Q-mean = ' num2str(mean(log(SqT)))]);
display(['Q-std.dev= ' num2str(sqrt(var(log(SqT))))]);