Apply Monte Carlo simulations to the Libor Market Model stochastic differential equation to model the expected value of a three-month spot rate 10 years from now!
% GIVEN CODES
f = repmat(0.05,40,1);
delta = 0.25;
vol=0.1;
for i=2:length(f)/2
vol(i,1)=vol(i-1)+0.006;
end
for i=length(f)/2+1:length(f)
vol(i,1)=vol(i-1)-0.006;
end
randn('state',0);
% GENERATES THE SAME STATE OF MONTE CARLO SIMULATION
clc
% Codes for the Monte Carlo Simulation
dt = .25;
sum = 0;
for i = 1:100
forwardrate = zeros(40,41);
forwardrate(:,1) = f;
cov = vol*vol';
for t = 2:41
e = randn;
dW = e*sqrt(dt);
for T = t-1:40
X = 0;
for k = t-1:T
X = X + delta*cov(k-t+2,T-t+2)*forwardrate(k,t-1)*dt/(1+delta*forwardrate(k,t-1));
end
forwardrate(T,t) = forwardrate(T,t-1) * (1+ sqrt(cov(T-t+2,T-t+2))*dW + X);
end
end
sum = sum + forwardrate(40,41);
end
% HENCE THE EXPECTATION RESULT
E = sum/100