# The Monte Carlo Method

Monte Carlo analysis is a technique where a model is created that simulates a particular process or business case. The model is then run many times to generate typical output values. By running the model many times, we can get a feel for the distribution of output values based on the inputs. The inputs to the model are generated randomly based on the values that they may actually take e.g. only within an allowable range, or clustered around a typical value. This technique enables us to generate an answer very close to reality in a fraction of the time and cost it would take to analyse exhaustively.

Consider the mini-app below, which uses the Monte-Carlo method to estimate the value of Pi. Pi is the area of a circle with radius 1, so by randomly guessing X/Y co-ordinates between 0 and 1, we can work out whether they are inside or outside the circle. The ratio of the number of points inside vs outside can be used to calculate an estimated value of Pi (roughly 3.14159).

The mini-app below demonstrates this for up to 5,000 points.

## Why use Monte-Carlo?

In business, it is often not possible to model every single scenario that could possibly arise because there are just too many possibilities to consider. Consider a 10-step process where each step can take one of 5 different values. The total number of combinations is 510, which is 9.7 million possible different outcomes. Even if a computer could run a full simulation every second, it would still take 113 days at 100% utilisation to calculate in full (over 3 months!). These kinds of scenarios make a full analysis uneconomical. And imagine if you waited 3 months for an answer, just to find out one of your inputs was wrong and had to run it again...

The Monte Carlo technique can be applied to almost any scenario. There is uncertainty in almost every aspect of business (and life in general), whether it's logistics, designing products or forecasting profits etc etc. In any situation where we need to understand the effects of uncertainty, Monte Carlo analysis is a great tool to have in the arsenal. There is even a saying that goes "All roads lead to Monte Carlo" because it is so simple, so versatile and so useful.

Imagine you own a business which buys wooden beams and joins them together before selling them on. The wooden beams that you buy are each 1m long and your joined beam must be 3m long. All beams must be the right length to within the nearest centimeter i.e. the beams you buy can be 99.5cm to 100.5cm long, and your finished beam must be within 299.5 and 300.5cm.

If you try to join together three beams which are each 0.5cm too long, your final beam will be 1.5cm too long and you will not be able to sell it, so it gets scrapped. You hire me to analyse the sitation and understand what proportion of your finished products are likely to be scrap.

We can take two approaches to compare and contrast results - exhaustive and Monte-Carlo.

• Exhaustive: We will model the full range of values for all 3 beams, in 100-step intervals. The total number of combinations therefore is 1 million.
• Monte-Carlo: You specify the number of combinations to run, and we randomly choose values in the allowable range for all 3 beams. The total number of combinations therefore is whatever you specify (be reasonable...).

Specify the number of combinations to run:

Exhaustive Results - Estimated scrap rate: -%. Time taken: - seconds.

Monte-Carlo Results - Estimated scrap rate: -%. Time Taken: - seconds.

Note: for simplicity, I have used a simple uniform distribution between 99.5cm and 100.5cm for each beam. Therefore, we are expecting the scrap rate to be exactly 33.3%. The simulation however shows how much more quickly we can reach this conclusion by being smarter in our analysis, rather than just trying every single combination.