10.8 Numerical Evaluation of Path Integrals
169
Npath=100000;
% sample paths
h=@(x)exp(-x.ˆ2/(2*(2*sigma)ˆ2)); % Metropolis-Hastings
x0=0.01; beta=3*sqrt(sigmaˆ2*dt);
y=metropolis3(h,beta,1000,x0);
% burn-in
x=metropolis3(h,beta,Npath*nslice,y(1000));
x=reshape(x,[nslice,Npath]);
After 1000 burn-in iterations, metropolis3() returns Npath*nslice random
numbers that are generated consecutively and therefore describe paths that are more
correlated than the uniformly generated random numbers from the previous example.
Most of the paths in his example therefore produce larger contributions to the path
integral. The reshape() command is used to recast the one-dimensional array x,
returned from metropolis3(), into the form where each column contains the
positions for one path.
After the preparation of the paths, we can re-use the calculation of the path integral,
discussed for the previous example, to calculate the path integral that describes the
pricing kernel. The right-hand side in Fig. 10.5 shows the numerically evaluated
kernel as asterisks and the analytical values by a dashed line. Note that using only
10
5 different paths in this example is sufficient to obtain a comparable accuracy to
the previous example where we use 2 × 10
7 uniformly distributed random numbers.
In a third example we prepare the sample paths by directly simulating the random
walk, where the step size is given by σ/
√
N with the number of slices N . We
artificially double the step size to give the process a chance to explore the tails of the
distribution; should the additional paths meander too far astray their large actions
suppresses their contribution to the path integral. Then we use the built-in cumsum()
function to cumulatively add the steps for each path.
Npath=10000;
% sample paths
x=2*randn(nslice,Npath)*sigma/sqrt(nslice);
x=cumsum(x,1);
The rest of the simulation stays the same. Exploring different number of paths, we
find that even as few as 10
4 paths are sufficient to approximate p BS reasonably well.
In practice, it is not possible to calculate the price for many options with analytical
methods and one has to resort to Monto-Carlo methods, such as those discussed in
this chapter. To explore this wide field further is, however, beyond our scope. Instead
we turn to the control of dynamical systems, either physical or macro-economic
systems. As opposed to the stock values on their random walk, which we cannot
control, let us explore whether we can do something about the economy as a whole?
Can we control that instead? Let us find out in the next chapter.
169
Npath=100000;
% sample paths
h=@(x)exp(-x.ˆ2/(2*(2*sigma)ˆ2)); % Metropolis-Hastings
x0=0.01; beta=3*sqrt(sigmaˆ2*dt);
y=metropolis3(h,beta,1000,x0);
% burn-in
x=metropolis3(h,beta,Npath*nslice,y(1000));
x=reshape(x,[nslice,Npath]);
After 1000 burn-in iterations, metropolis3() returns Npath*nslice random
numbers that are generated consecutively and therefore describe paths that are more
correlated than the uniformly generated random numbers from the previous example.
Most of the paths in his example therefore produce larger contributions to the path
integral. The reshape() command is used to recast the one-dimensional array x,
returned from metropolis3(), into the form where each column contains the
positions for one path.
After the preparation of the paths, we can re-use the calculation of the path integral,
discussed for the previous example, to calculate the path integral that describes the
pricing kernel. The right-hand side in Fig. 10.5 shows the numerically evaluated
kernel as asterisks and the analytical values by a dashed line. Note that using only
10
5 different paths in this example is sufficient to obtain a comparable accuracy to
the previous example where we use 2 × 10
7 uniformly distributed random numbers.
In a third example we prepare the sample paths by directly simulating the random
walk, where the step size is given by σ/
√
N with the number of slices N . We
artificially double the step size to give the process a chance to explore the tails of the
distribution; should the additional paths meander too far astray their large actions
suppresses their contribution to the path integral. Then we use the built-in cumsum()
function to cumulatively add the steps for each path.
Npath=10000;
% sample paths
x=2*randn(nslice,Npath)*sigma/sqrt(nslice);
x=cumsum(x,1);
The rest of the simulation stays the same. Exploring different number of paths, we
find that even as few as 10
4 paths are sufficient to approximate p BS reasonably well.
In practice, it is not possible to calculate the price for many options with analytical
methods and one has to resort to Monto-Carlo methods, such as those discussed in
this chapter. To explore this wide field further is, however, beyond our scope. Instead
we turn to the control of dynamical systems, either physical or macro-economic
systems. As opposed to the stock values on their random walk, which we cannot
control, let us explore whether we can do something about the economy as a whole?
Can we control that instead? Let us find out in the next chapter.
