clear
set(gcf, 'PaperOrientation', 'landscape');
set(gcf, 'PaperUnits', 'centimeters');
set(gcf, 'PaperType', 'A4');
myfiguresize = [.63, .63, 28.41, 19.72];
set(gcf, 'PaperPosition', myfiguresize);
S0 = 10;
mu = .02;
sigma = .2;
Delta_t = 1;
soglia = 7;
griglia = 500;
num_paths = 100;
for i=1:num_paths
    log_S = brownian(griglia, mu-.5*sigma^2, sigma, Delta_t);
    S = exp(log_S);
    ultimo_log(i) = log_S(griglia+1);
    ultimo_prezzo(i) = S(griglia+1);
    ultimo_log_drift(i) = log_S(griglia+1)+log(S0);
    ultimo_prezzo_drift(i) = exp(ultimo_log_drift(i));
    log_S_drift = log_S+log(S0);
    S_drift = exp(log_S_drift);
    plot(S_drift,'color','k')
    hold on
end
hold on
x = S0-6:.001:S0+10;
media = log(S0) + (mu - .5 * sigma^2) * Delta_t;
title([num2str(num_paths) ' percorsi simulati da un moto browniano con \mu= ' num2str(mu) ', \sigma = ' num2str(sigma) ', S_0 = ' num2str(10)], 'FontWeight', 'bold', 'FontSize', 12, 'FontName', 'garamond');
set(gca,'XTickLabel',' ')
xlabel('tempo')
ylabel('valore dell''attivo')

media = (mu-.5*(sigma^2)) * Delta_t;
PD = normcdf((log(soglia/S0)-media)/sigma,0,1)
