1. Leveraging Monte Carlo simulations
Let's talk about situations where Monte Carlo simulations are most useful.
2. Wide applicability
Monte Carlo simulations are used in many different fields,
such as finance,
engineering,
and physical sciences.
3. Stock price prediction
In finance, they are used to simulate possible outcomes for a stock price, along with outcome probabilities over a certain period.
4. Risk management
They are also used in value at risk calculations, which calculate worst-case scenarios, such as how much an investor stands to lose in a really bad month. Here, the most an investor expects to lose is 1,000 dollars with 90% confidence.
5. Binding site identification
Monte Carlo simulations are also used in a variety of physical science applications such as identifying protein binding sites.
6. Reliability analysis in engineering
In engineering, the mechanical modeling of physical systems is often complicated by the presence of uncertainties. To assess reliability, Monte Carlo simulations are used to estimate probabilities of failure and to define domains of safety and failure.
7. Benefits of Monte Carlo Simulations
There are many benefits of utilizing Monte Carlo simulations.
They take into consideration a range of values for various inputs.
They show not only what could happen, but how likely each outcome is.
They make it easy to create graphs that show the range of possible outcomes in a scenario.
Finally, they allow us to examine what would have happened under different circumstances.
8. Bags of biased dice
Let's look at an example showcasing these benefits! We'll roll two dice chosen from two bags.
The bags defined here contain three lists; each list represents the six sides of a biased die.
In this simulation, we pick one die from each bag randomly and roll both dice.
If the roll adds up to exactly eight, we have a success. If not, it's a failure.
We can use a Monte Carlo simulation to calculate the probability of success for each unique combination of dice.
9. Biased dice simulation
We start with a function called roll_biased_dice, which accepts n number of trials as an argument. The results dictionary records simulation results.
For each trial, we generate four random numbers: bag_index1 for picking a random die from bag1, and die_index1 for sampling a random side of that die. We similarly define bag_index2 and die_index2 to get a random side of a die in bag2.
point1 and point2 are the points rolled from these two dice.
We define a key variable that assigns a name to each combination of dice rolled. For example, if point_1 is three and point_2 is six, the key will be 3-underscore-six.
When points one and two add up to eight, we record this success in dice_results, adding the key if it's not already present.
10. Biased dice results
Here's a look at the roll_biased_dice results with 10,000 trials. The table shows all the combinations of die points that create a success along with the probability that each combination of points will occur given our biased dice.
11. Biased dice results
It is easy to visualize the summary data and the likelihood of all possible outcomes for the two bags of biased dice we defined earlier.
12. Biased dice results
It's also easy to examine different conditions: we can run the same simulation with two totally different bags of biased dice and visualize those outcomes as well!
13. Limitations of Monte Carlo simulations
Of course, Monte Carlo simulations also have limitations. As the saying goes: all models are wrong; some are useful.
For our models to be useful, we need to have fair assumptions. A model's output is only as good as its input!
Monte Carlo simulations also tend to underestimate the probability of extreme events such as the irrational behaviors sometimes exhibited by market participants in finance. Simulations need to be good mimics of the system of interest to produce relevant results.
14. Let's practice!
Let's move on to the exercises!