## Project 1: Analyzing Monte Carlo Integration

December 1, 2010

One of the methods used extensively in mathematical finance is the Monte Carlo method. A Monte Carlo method is “Any method which solves a problem by generating suitable random numbers and observing that fraction of the numbers obeying some property or properties. The method is useful for obtaining numerical solutions to problems which are too complicated to solve analytically. It was named by S. Ulam, who in 1946 became the first mathematician to dignify this approach with a name, in honor of a relative having a propensity to gamble …” (from Weisstein, Eric W. ”Monte Carlo Method.” From MathWorld–A Wolfram Web Resource. ,http://mathworld.wolfram.com/MonteCarloMethod.html.)

We don’t have the time or the background to thoroughly explore the huge variety of Monte Carlo methods, and the complicated problems they are used to solve, especially in mathematical finance. However, we can get some insight into basic Monte Carlo methods with some well-chosen examples. In fact, we will use the probability theory that we have developed to analyze the likely error that this probabilistic method creates.

Recall that $E\left[X\right]={\int }_{-\infty }^{\infty }xf\left(x\right)\phantom{\rule{0em}{0ex}}dx$ where $f\left(x\right)$ is the p.d.f. of the random variable $X$. Slightly generalizing, $E\left[G\left(X\right)\right]={\int }_{-\infty }^{\infty }G\left(x\right)f\left(x\right)\phantom{\rule{0em}{0ex}}dx$ when $G\left(\cdot \right)$ is some function defined on the range of $X$. We have already used this idea when we defined the m.g.f.

Suppose we wish to numerically evaluate $J={\int }_{0}^{\pi ∕2}cos\left(x\right)\phantom{\rule{0em}{0ex}}dx$ reliably to some specified relative error. (Although we can evaluate this integral with basic calculus, pretend that this is an integral which is too complicated to solve analytically. ) We notice that we could consider

${\int }_{0}^{\pi ∕2}cos\left(x\right)\phantom{\rule{0em}{0ex}}dx=\frac{\pi }{2}{\int }_{0}^{\pi ∕2}cos\left(x\right)\frac{2}{\pi }\phantom{\rule{0em}{0ex}}dx$

and that

$E\left[cos\left(X\right)\right]={\int }_{0}^{\pi ∕2}cos\left(x\right)\frac{2}{\pi }\phantom{\rule{0em}{0ex}}dx$

is the mean of $cos\left(X\right)$, where $X$ is a uniformly distributed random variable on $\left[0,\pi ∕2\right]$. Therefore

$J=\frac{\pi }{2}E\left[cos\left(X\right)\right].$

But we have another way to evaluate the mean and therefore the integral, namely

${J}_{n}=\frac{\pi }{2}\cdot \frac{1}{n}\sum _{i=1}^{n}cos\left({X}_{i}\right)$

where the ${X}_{k}$ are uniformly distributed random numbers on the interval $\left[0,\pi ∕2\right]$.

1. For preliminary reference, use calculus to symbolically evaluate $\mu =E\left[cos\left(X\right)\right]$ and ${\sigma }^{2}=Var\left[cos\left(X\right)\right]$. Numerically evaluate both to at least 5 places of accuracy.
2. Express the mean and variance of ${J}_{n}$ in terms of $\mu$ and ${\sigma }^{2}$ respectively.
3. Justify that
$\frac{{J}_{n}-J}{\sqrt{Var\left[{J}_{n}\right]}}$

is approximately normally distributed, and specify the mean and variance of the distribution.

4. Now find $z$ so that
$ℙ\left[|\frac{{J}_{n}-J}{\sqrt{Var\left[{J}_{n}\right]}}|

5. The absolute error of the estimate is $|{J}_{n}-J|$. We desire that with probability greater than $0.99$, the absolute error from our experiment be less than 0.05. Find a value of $n$ large enough that the experiment reliably (probability $>0.99$ ) generates this level of accuracy.
6. Using some software, (A spreadsheet program such as Excel is sufficient, but other software such as Maple, Mathematica, Octave, Matlab, R, perl, and Python will also be satisfactory) actually do the Monte Carlo method to evaluate ${\int }_{0}^{\pi ∕2}cos\left(x\right)\phantom{\rule{0em}{0ex}}dx$.
7. Calculate the integral
$J={\int }_{0}^{\pi ∕2}sin\left(x\right)\phantom{\rule{0em}{0ex}}dx$

by a Monte Carlo method so that with probability $P\ge 0.99$ the absolute error will not exceed $0.05$. Use only the intuition gained from the previous analysis.