Monte Carlo Simulation
From ForcaWiki, the simple encyclopedia
| In one sentence | A way to solve a hard problem by trying it many times with random chance and seeing how the results turn out on average. |
|---|---|
| Category | Mathematics |
| Related | Probability, Markov Chains, Pi |
Suppose you want to know your chances of winning a certain board game. One way is to sit down with a math expert and work out the odds with careful equations, which can be really hard. But there is another way that is often much easier: just play the game a thousand times, keep score, and see how often you win. If you win about 300 out of 1000 games, your chance of winning is roughly 3 in 10.
That second way, learning the answer by trying something many times with random luck and counting the results, is the heart of a Monte Carlo simulation. It is a trick for cracking hard problems using lots and lots of random tries instead of difficult math.
How does it work?
A Monte Carlo simulation usually goes like this:
- Set up the thing you want to study, such as a game, a dice roll, or a business plan.
- Run it once using random chance, and write down what happened.
- Do that again and again, thousands or even millions of times.
- Look at all the results together. The average of all those tries is your answer.
The more times you run it, the closer your answer usually gets to the truth. Because computers can do millions of random tries in seconds, they are perfect for this.
A surprising example: measuring a circle with darts
Here is a famous Monte Carlo trick. Draw a circle inside a square, then throw darts at the square completely at random, as if with your eyes closed. Some darts land inside the circle, and some land in the corners outside it.
If you throw enough darts and count what fraction of them landed inside the circle, that number turns out to be directly connected to the special number Pi, the one that shows up in every circle. So with enough random darts, you can measure pi without ever using a ruler or a formula, just by counting. It feels almost like magic, but it is really just chance doing the work.
Where it is used
Monte Carlo simulations show up anywhere the future is uncertain and the math is too hard to do exactly:
- Weather forecasters use them to see how a storm might play out.
- Money experts use them to measure how risky an investment might be, by imagining thousands of possible futures.
- Scientists and engineers use them to test designs, from bridges to spacecraft.
- Some game-playing computers get smart by imagining thousands of random ways a game could go before choosing their move.
Fun facts
- Monte Carlo simulation is named after the famous Monte Carlo casino in Monaco, because it leans on chance and luck, just like the games in a casino.
- It was invented in the 1940s by scientists working on the first atomic bombs. One of them, Stanislaw Ulam, got the idea while playing a card game of solitaire and wondering what his chances of winning were.
- The method is a close cousin of Markov Chains, and experts often combine the two to explore problems that would otherwise be impossible to solve.