Code covered by the BSD License  

Highlights from
Approaches to implementing Monte Carlo methods in MATLAB

image thumbnail

Approaches to implementing Monte Carlo methods in MATLAB

by

 

28 Sep 2011 (Updated )

Code for the article in the September 2011 article http://www.wilmott.com/magazine.cfm

TimingScriptQuasi.m
% Timing script to test scripts using Quasi Random numbers
%
% See article "Approaches to implementing Monte Carlo methods in MATLAB"
% by Sri Krishnamurthy,CFA and Jorge Paloschi,PHD
% in the September 2011 article of Wimott Magazine or at
% http://www.wilmott.com/magazine.cfm 
%
% Copyright 2011 MathWorks, Inc.
nSims = 100000;
tStart=tic;
P1= PriceArithmeticAsianOptionQuasi(50,50,.1,5/12,.4,150,nSims,'Sobol');
tElapsed1 = toc(tStart);

tStart=tic;
P2=PriceArithmeticAsianOptionQuasi(50,50,.1,5/12,.4,150,nSims,'Halton');
tElapsed2 = toc(tStart);

tStart=tic;
P3=PriceArithmeticAsianOptionQuasi(50,50,.1,5/12,.4,150,nSims,'LHS');
tElapsed3 = toc(tStart);

tStart=tic;
P4=PriceArithmeticAsianOptionV(50,50,.1,5/12,.4,150,nSims);
tElapsed4 = toc(tStart);

figure
subplot(2,1,1)
bar([tElapsed1 tElapsed2 tElapsed3 tElapsed4]);
xlabel('Test cases');
ylabel('Time in seconds');

subplot(2,1,2);
bar([P1 P2 P3 P4]);
xlabel('Test cases');
ylabel('Option prices');

Contact us