Take the 2-minute tour ×

I've recently been interested in Monte Carlo simulations and their uses, unfortunately most of the examples I find are difficult to understand for a beginner. What are some simple examples of using Monte Carlo simulations used to solve math problems? Bonus points for showing a simple example and using it to understand a more complex one.

share|improve this question
I posted an answer to a different question that may be interesting to you, it discusses a simple Monte Carlo approximation of pi. CW? –  Tom Stephens Aug 16 '10 at 19:16
You can see a description in the Wikipedia on how the Buffon's needle[1] experiment is related with $\pi$ and a link to "Estimating PI Visualization (Flash)[2]". [1]: en.wikipedia.org/wiki/Buffon%27s_needle [2]: metablake.com/pi.swf –  Américo Tavares Aug 16 '10 at 21:44
One should, BTW, distinguish between Monte Carlo algorithms, which can only compute approximations, and Las Vegas algorithms which, even with the "random" component of the algorithm, gives an exact answer. –  Ｊ. Ｍ. Aug 16 '10 at 22:25

4 Answers 4

up vote 7 down vote accepted

Monte Carlo methods are very useful in numerically evaluating high-dimensional integrals. With traditional integration methods, the number of integrand evaluations required to maintain accuracy grows quickly as dimension increases. With Monte Carlo integration, the number of integrand evaluations needed is independent of dimension. For many high-dimensional integrals, Monte Carlo methods are the only practical choice.

share|improve this answer
Probably a bit inaccurate to say "only practical choice"; "quasi-Monte Carlo" methods (i.e. using more "deterministic" sequences like the Niederreiter or Sobol sequences instead of a PRNG) can sometimes give better results than Monte Carlo proper. –  Ｊ. Ｍ. Aug 16 '10 at 22:23
True. I was implicitly including quasi-Monte Carlo with Monte Carlo. An interesting variation is randomized QMC, randomly shifting QMC sequences to get more accuracy on some problems than either MC or QMC separately. –  John D. Cook Aug 17 '10 at 16:01
Indeed, all different variations of sampling n-space as sparsely as one can get while still getting usable answers. –  Ｊ. Ｍ. Aug 17 '10 at 16:36

Monte Carlo methods are used extensively in financial mathematics for the pricing of complex or "exotic" financial derivatives. With equity options, for example, the value of the stocks in the option contract is simulated using a stochastic process and parameters that can be observed or derived from other financial instruments. This process is computationally very intensive resulting in many investment banks having server farms of tens of thousands of machines dedicated to the pricing and risk management of derivatives.

share|improve this answer

Tangential to John D. Cook's reply, and also somewhat related: Monte Carlo also finds application in the solution of (partial, stochastic) differential equations, of which cubature (nobody ever uses MC in the one-dimensional case practically ;) ) is but a specialized case. As already mentioned by John, the pain dealt by the "curse of dimensionality" stings less with Monte Carlo.

share|improve this answer

EDIT: a previous comment posted the same answer, I just noticed

You could use montecarlo method to approximate pi. You basically define a square of side length 2 and inscribe a circle of radius 1 in it. Let the center of the circle be at the origin. Use a random number generator to pick an x-coordinate between 0 and 1 and a y-coordinate between 0 and 1.

number of pts in the circle / number of pts in square ~ pi/4

This is the simplest example of a monte carlo code I know and I think it is probably the standard example.

share|improve this answer

Your Answer


