Answer 4

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Question 4

Step Size
0.01
0.001
Step Size
0.01
0.001

Expected Value
M=1000 M=1500 M=2000
10.456
10.383
10.395
10.361
10.374
10.448
Variances
M=1000 M=1500 M=2000
0.55743 0.50292 0.52438
0.49097 0.53669 0.55306

Comment: We see that as the number of steps increase, the variance of the estimation decreases
significantly. We can apply some variance reduction techniques to reduce this variance. Also
number of simulations will have to be squared to reduce the variance in half which can be
computationally expensive.

%matlab code
mu=.02;
sigma=.05;
S_0=10;
T=2;
dt=[.01 .001];
M=[1000 1500 2000];
expected_val=nan(2,3);
Variances=nan(2,3);
%plotter=nan((T/dt(1))+1,2);
for i=1:length(dt)
numsteps=T/dt(i);
x=randn(numsteps,sum(M));
stock_prices=nan(numsteps+1,sum(M));
stock_prices(1,:)=S_0*ones(1,sum(M));
checker=0;
for j=2:numsteps+1
stock_prices(j,:)=stock_prices(j-1,:).*(1*ones(1,sum(M))+...
mu*dt(i)*ones(1,sum(M))+sqrt(dt(i))*sigma*x(j-1,:));
checker=checker+dt(i);
end
checker
expected_val(i,:)=[mean(stock_prices(end,1:1000)) mean(stock_prices(end,1001:2500))...
mean(stock_prices(end,2501:end))];
Variances(i,:)=[var(stock_prices(end,1:1000)) var(stock_prices(end,1001:2500))...
var(stock_prices(end,2501:end))];
if i==1
plotter=stock_prices(:,1:2);
end
end
plot(plotter)
xlabel('Step No')
ylabel('Stock Value')
title('Two Paths for the price process t=.01')
expected_val
Variances
csvwrite('nmfans1.csv',expected_val)
csvwrite('nmfans2.csv',Variances)

You might also like