Monte Carlo Simulation
What is the Monte Carlo Simulation?
The Monte Carlo simulation is a mathematical technique that predicts possible outcomes of an
uncertain event. Computer programs use this method to analyze past data and predict a range of
future outcomes based on a choice of action. For example, if you want to estimate the first month’s
sales of a new product, you can give the Monte Carlo simulation program your historical sales data.
The program will estimate different sales values based on factors such as general market conditions,
product price, and advertising budget.
Why is the Monte Carlo simulation important?
The Monte Carlo simulation is a probabilistic model that can include an element of uncertainty or
randomness in its prediction. When you use a probabilistic model to simulate an outcome, you will
get different results each time. For example, the distance between your home and office is fixed.
However, a probabilistic simulation might predict different travel times by considering factors such as
congestion, bad weather, and vehicle breakdowns.
In contrast, conventional forecasting methods are more deterministic. They provide a definite answer
to the prediction and cannot factor in uncertainty. For instance, they might tell you the minimum and
maximum travel time, but both answers are less accurate.
Benefits of the Monte Carlo simulation
The Monte Carlo simulation provides multiple possible outcomes and the probability of each from a
large pool of random data samples. It offers a clearer picture than a deterministic forecast. For
instance, forecasting financial risks requires analyzing dozens or hundreds of risk factors. Financial
analysts use the Monte Carlo simulation to produce the probability of every possible outcome.
What are the Monte Carlo simulation use cases?
Companies use Monte Carlo methods to assess risks and make accurate long-term predictions. The
following are some examples of use cases.
Business
Business leaders use Monte Carlo methods to project realistic scenarios when making decisions. For
example, a marketer needs to decide whether it's feasible to increase the advertising budget for an
online yoga course. They could use the Monte Carlo mathematical model on uncertain factors
or variables such as the following:
Subscription fee
Advertising cost
Sign-up rate
Retention
The simulation would then predict the impact of changes on these factors to indicate whether the
decision is profitable.
Finance
Financial analysts often make long-term forecasts on stock prices and then advise their clients of
appropriate strategies. While doing so, they must consider market factors that could cause drastic
changes to the investment value. As a result, they use the Monte Carlo simulation to predict
probable outcomes to support their strategies.
Online gaming
Strict regulations govern the online gaming and betting industry. Customers expect gaming software
to be fair and mimic the characteristics of its physical counterpart. Therefore, game programmers use
the Monte Carlo method to simulate results and ensure a fair-play experience.
Engineering
Engineers must ensure the reliability and robustness of every product and system they create before
making it available to the public. They use Monte Carlo methods to simulate a product’s probable
failure rate based on existing variables. For example, mechanical engineers use the Monte Carlo
simulation to estimate the durability of an engine when it operates in various conditions.
How does the Monte Carlo simulation work?
The basic principle of the Monte Carlo simulation lies in ergodicity, which describes the statistical
behavior of a moving point in an enclosed system. The moving point will eventually pass through
every possible location in an ergodic system. This becomes the basis of the Monte Carlo simulation,
in which the computer runs enough simulations to produce the eventual outcome of different inputs.
For example, a six-sided die has a one-sixth chance of landing on a specific number. When you roll
the die six times, you might not land the die on six different numbers. However, you will achieve the
theoretical probability of one-sixth for each number when you continue indefinitely rolling. The
result accuracy is proportional to the number of simulations. In other words, running 10,000
simulations produces more accurate results than 100 simulations.
The Monte Carlo simulation works the same way. It uses a computer system to run enough
simulations to produce different outcomes that mimic real-life results. The system uses random
number generators to recreate the inherent uncertainty of the input parameters. Random number
generators are computer programs that produce an unpredictable sequence of random numbers.
What are the components of a Monte Carlo simulation?
A Monte Carlo analysis consists of input variables, output variables, and a mathematical model. The
computer system feeds independent variables into a mathematical model, simulates them, and
produces dependent variables.
Input variables
Input variables are random values that affect the outcome of the Monte Carlo simulation. For
example, manufacturing quality and temperature are input variables that influence a smartphone's
durability. You can express input variables as a range of random value samples so Monte Carlo
methods can simulate the results with random input values.
Output variable
The output variable is the result of the Monte Carlo analysis. For example, an electronic device’s life
expectancy is an output variable, with its value being a time such as 6 months or 2 years. The Monte
Carlo simulation software shows the output variable in a histogram or graph that distributes the
result in a continuous range on the horizontal axis.
Mathematical model
A mathematical model is an equation that describes the relationship between output and input
variables in mathematical form. For example, the mathematical model for profitability is Profit =
Revenue − Expenses.
The Monte Carlo software replaces revenue and expenses with probable values based on the
probability distribution type. Then it repeats the simulation to get a highly accurate result. The
Monte Carlo simulation can run for hours when the mathematical model involves many random
variables.
What are the steps in performing the Monte Carlo simulation?
The Monte Carlo method involves the following steps.
Establish the mathematical model
Define an equation that brings the output and input variables together. Mathematical models can
range from basic business formulas to complex scientific equations.
Determine the input values
Choose from the different types of probability distributions to represent the input values. For
example, the operating temperature of a mobile phone is likely to be a bell curve since the device
runs at room temperature most of the time.
Create a sample dataset
Create a large dataset of random samples based on the chosen probability distribution. The sample
size should be in the range of 100,000 to produce accurate results.
Set up the Monte Carlo simulation software
Use the input samples and mathematical model to configure and run the Monte Carlo simulation
software. Result times can vary depending on the number of input variables, and you might have to
wait for the results.
Analyze the results
Check the simulated results to find how the output distributes on the histogram. Use statistical tools
to calculate parameters, such as mean value, standard deviation, and variant, to determine whether
the result falls within your expectation.
What are the challenges of the Monte Carlo simulation?
These are two common challenges when using Monte Carlo simulations:
The Monte Carlo simulation is highly dependent on the input values and distribution. If
mistakes are made when electing the input and probability distribution, it can lead to
inaccurate results.
It might take excessive computational power to perform Monte Carlo experiments. Computing with
the Monte Carlo method can take hours or days to complete on a single computer.
Estimating the value of Pi using Monte Carlo
Monte Carlo estimation
Monte Carlo methods are a broad class of computational algorithms that rely on repeated random
sampling to obtain numerical results. One of the basic examples of getting started with the Monte
Carlo algorithm is the estimation of Pi.
Estimation of Pi
The idea is to simulate random (x, y) points in a 2-D plane with domain as a square of side 2r units
centered on (0,0). Imagine a circle inside the same domain with same radius r and inscribed into the
square. We then calculate the ratio of number points that lied inside the circle and total number of
generated points. Refer to the image below:
We know that area of the square is 4r2 unit sq while that of circle is πr2. The ratio of these two areas
is as follows :
The beauty of this algorithm is that we don’t need any graphics or simulation to display the
generated points. We simply generate random (x, y) pairs and then check if x2+y2<=1. If yes, we
increment the number of points that appears inside the circle. In randomized and simulation
algorithms like Monte Carlo, the more the number of iterations, the more accurate the result is.
Thus, the title is “Estimating the value of Pi” and not “Calculating the value of Pi”.
Below is the algorithm for the method:
The Algorithm
1. Initialize circle_points, square_points and interval to 0.
2. Generate random point x.
3. Generate random point y.
4. Calculate d = x*x + y*y.
5. If d <= 1, increment circle_points.
6. Increment square_points.
7. Increment interval.
8. If increment < NO_OF_ITERATIONS, repeat from 2.
9. Calculate pi = 4*(circle_points/square_points).
10. Terminate.