I'm creating a Monte Carlo simulation model which I use to price an European option with various pay-off conditions, hence I can't use Black Scholes.

I want to stop the simulation once I am 95% sure I am within 1% of the true value.

To do this, I calculate the relative error (correct naming?) every 10 000 sims using:

$$Relative Error = \frac{(\sigma/\sqrt{n}) Z_{\delta/2}}{\mu} $$

Where $$\sigma/\sqrt{n}$$ represent the standard error and $$Z_{\delta/2}$$ my confidence level, so 1.96 for 95%.

μ is the mean (fair value) of the simulation.

If the relative error is less than let's say 1%, then I stop the simulation.

Is this the correct way of solving my problem?

  • $\begingroup$ How do you know $\mu$? Isn't that the value you are estimating? $\endgroup$ – bcf Nov 16 '15 at 15:56

Yes, that's an excellent approach. The only time it might go wrong is if, say, you are integrating on some extreme tail event without using importance sampling.

For example, let's say you were simulating expected loss on a portfolio of five bonds issued by the USA, Germany, Norway, Sweden and the Netherlands. After 10,000 simulations, there's a chance you might still not have generated any paths with defaults, in which case $\sigma=0$ and your algorithm would halt.

  • $\begingroup$ Excellent, thanks! I don't have any extreme tail events, but good to know if that ever changes. $\endgroup$ – Johan Nov 16 '15 at 15:51

You have the right idea, but it seems you don't know $\mu$, so using it in your error check doesn't seem correct. Also, checking the result every 10,000 iterations may not be optimal for deciding when to stop.

To be clear, let $E(X) = \mu$ and $Var(X) = \sigma$. We're invoking the CLT when we write $$ P\left( \left|\frac{\bar{X}_n - \mu}{\sigma/\sqrt{n}}\right| > 1.96 \right) \approx P(|Z| > 1.96) = 0.05. $$ In words, there is approximately a 95% probability that the sample mean $\bar{X}_n$ is within $1.96\frac{\sigma}{\sqrt{n}}$ units of the true mean $\mu$.

How do we use this in simulation? First, note $$ S_n^2 := \frac{1}{n-1}\sum_{i=1}^n (X_i - \bar{X})^2 $$ is an unbiased estimator of $\sigma^2$. Thus if we want an approximate 95% probability that $\bar{X}_n$ is within $0.01$ units of $\mu$, we continue simulation until $$ 1.96\frac{S_n}{\sqrt{n}} < 0.01. $$

There are two important items to note:

  1. We should have $n \geq 30$ to use this error check since this is a result of the CLT, and
  2. An online implementation of $\bar{X}_n$ and $S_n^2$ would be much more efficient, so that we don't recompute them every time.

For item 2, we may use \begin{align} \bar{X}_{n+1} & = \bar{X}_n + \frac{X_{n+1} - \bar{X}_n}{n+1}, \\ S^2_{n+1} & = \left(1 - \frac{1}{n}\right)S_n^2 + (n+1)(\bar{X}_{n+1} - \bar{X}_n)^2 \end{align} Now we may simply use a while($1.96\frac{S_n}{\sqrt{n}} > 0.01$) loop, stopping at exactly the iteration this error is met.

  • $\begingroup$ If you use that equation in the while loop, doesn't that mean my absolute error should be within 0.01? I'm looking for a way to know when my relative error is within 0.01. μ is my estimated mean, not the true mean. However, I would imagine it has to be included somewhere in order to calculate the relative error? Or am I missing something? $\endgroup$ – Johan Nov 16 '15 at 16:47
  • $\begingroup$ @Johan That is actually an interesting question - how to use relative error in MC? Relative error is defined as $\frac{\bar{X}_n - \mu}{\mu}$, and I would be careful replacing the $\mu$ on the bottom with $\bar{X}_n$ as this would introduce an additional error. But, yes I gave an absolute error result, which I feel is useful for quant applications (error within 1 penny, e.g.) $\endgroup$ – bcf Nov 16 '15 at 17:31
  • $\begingroup$ I have a question regarding how one exactly estimates the error of the mean which is your $\mu$. I have posed a question on this problem quant.stackexchange.com/q/39604/6686. Please check it out. Is there a reference on this subject? $\endgroup$ – Hans May 4 '18 at 19:37

Your Answer

