Tiempo de impago
% Time to default of IBM Bond
% Montecarlo simulation of Time
% Time follows an exponential distribution with Intensity lambda=1/Average T
% We double check the simulation with the Cumulative Distribution Function F
lambda=0.01
iterations=1000000
average=1/lambda
lbound=5
ubound=50
serie = exprnd(average,iterations,1);
%over_ubound=(serie>ubound); sides= (serie>lbound) & (serie %results=sum(over_ubound) results=sum(sides) proba=results/iterations %check
%below_lbound=(serie
%results=sum(below_lbound)
check=expcdf(ubound,average)-expcdf(lbound,average)
