168
10 Quantum Finance and Path Integrals
Fig. 10.5 The asterisks show the pricing kernel, evaluated by using 2 × 10 7 paths constructed from
uniformly distributed random numbers (left), and evaluated using 10 5 paths that are generated by
the Metropolis-Hastings algorithm (right). The red dashed lines indicate the analytical result from
(10.22)
allocate space for the path_integral, and loop over all paths. Inside the loop
we add the contribution of each path to the appropriate grid point.
ix=round(x(end,:)/(sigma/5)); ixmin=min(ix); ixmax=max(ix);
xx=(ixmin:ixmax)*sigma/5;
path_integral=zeros(1,ixmax-ixmin+1);
for k=1:Npath
ipos=ix(k)-ixmin+1;
path_integral(ipos)=path_integral(ipos)+eSBS(k);
end
i0=(xx(2)-xx(1))*sum(path_integral); % normalize
path_integral=exp(-rf*t)*path_integral/i0;
Finally, we calculate the normalized path integral using the previously determined
normalization constant i0 and include the discount factor e
−r f τ . The left-hand side
in Fig. 10.5 shows the numerically evaluated pricing kernel p BS as asterisks, whereas
the red dashed line shows the analytic result from (10.22) or (10.69). For this plot,
we used 2 × 10
7 sample path to evaluate the path integral. Smaller numbers lead to
significant deviations of the numerical result from the analytical results. Despite the
large number of path is the running time only a few seconds on a desktop computer.
The MATLAB script used to prepare the plot is reproduced in Appendix B.6. The
reader is encouraged to vary the parameters and explore how the plot changes.
In a second example we employ the Metropolis-Hastings algorithm to generate
the paths. All we have to do is to replace the path-generation algorithm by the
following code, which first defines the desired number of paths and then specifies
the distribution of random numbers to follow a Gaussian distribution with a rms of
3σ. Next, the starting value x0 and β for the metropolis3() function, discussed
in the previous section and reproduced in Appendix B.5, are defined.
Précédent

- 176/292

Suivant