Real-life is full of uncertainties. But, that does not mean that we have to leave everything on fate. There is a way to estimate uncertainties. And that is what Monte Carlo Simulation does. In order to understand Monte Carlo Simulation, first, let's talk about Random Variables. You know that,

**Profit = Revenue - Expense**

If you want to look back your past year, yes, you know the value of revenue and expense from the past year. You can plug in those numbers to the given equation and get a value for Profit, which is also a calculated and known number.

But, when you want to predict your future, you do not know what will be your expense and what will be your revenue. So, you cannot calculate your future profit directly.

You may think of a way to estimate the range of possible values of profit like this:

If your Revenue will be 100$, and the Expense will be 20$, then your profit will be 80$.

If your Revenue will be 200$, and your Expense will be 30$, your profit will be 170$.

.........

An unlimited number of statements can be drawn from the above equation. No, it is not a nice way. There can be an unlimited number of combinations which is not possible to manage.

But, say, you can guess a probability distribution of your expense and revenue (based on your experience and history), then, you should be able to estimate your profit, in terms of a probability distribution.

So, your refined formula for calculating profit should become:

**Probability Distribution of Profit = Probability Distribution of Revenue - Probability Distribution of Expense**

Now, the question is, how can you deduct one probability distribution from another. A probability distribution is not a single number that you can simply type into your calculator and hit the big PLUS button or the minus button.

The answer is "**Monte Carlo Simulation**". Using Monte Carlo Simulation, you can get the value of "Profit" as a Random Variable when your Revenue and Expenses are random variables.

Monte Carlo Simulation is a technique that performs random sampling to achieve such a goal. So, let's clarify what Random Sampling is.

#### Random Sampling

Think about this **probability wheel** or a roulette.

If you spin this roulette and stop, what do you expect to get on average? "Red" or "Blue"? You can expect that, out of 4 times, 3 times you may get "Red" and 1 time you can get "Blue", right? Because red covers 75% of the disc and blue covers 25% of the disc. In another word, "red" and "blue" follows a probability distribution, as red -> 0.75, blue -> 0.25. Random Sampling is a sampling technique, where a probability wheel is created according to the probability distribution of various numbers and taken a sample from the probability wheel.

For example, say you have probability distribution like this:

So, if you want to get a random sample from this probability distribution, you can create a probability wheel where each value or outcome will represent a pie in that wheel and the area of that pie will be proportional to the probability of that outcome, which you will get from the probability distribution. Notice that the probability of 30 is 0.02 in the given triangular probability distribution. So, there will be a pie representing the value of 30, in your probability wheel and that pie will cover 2% of the wheel area. Once you create such a probability wheel, if you spin and stop 100 times, you can expect 2 times, the pie for number 30 will show up. For every probability distribution, there is a mathematical formula available for such a hypothetical probability wheel. Most of them are complex to calculate. But, when you use the SpiceLogic Rational Will or Decision Tree Software, the software will take care of such calculation, while you can focus on the big picture of your decision problem.

#### How Monte Carlo Simulation can evaluate the function of Random Variables.

Ok, so far, you understood what a Random Variable and Random sampling are. Say, you are a project manager of a project where you need to predict the profit of your next project, where you have evaluated the probability distribution of Revenue and Cost from various statistical data.

Say, your Revenue follows a Probability Distribution (Normal Distribution) as shown below.

And Expense follows a probability Distribution (Triangular Probability Distribution) as shown below.

As we already mentioned, if you think of creating many combinations like:

Combination 1: Revenue is 500$, Expense is 300$

Combination 2: Revenue is 501$, Expense is 301$

….

.....

You will be overwhelmed. You cannot manage to get all these combinations like this way, right?

Here 'Monte Carlo Simulation' comes into the rescue. What you need to do is, take a random sample from the Revenue probability distribution. Say, you got 500$. Then, take a random sample from the Expense probability distribution. Say, you got 200$. So, for the first round sampling, your total profit is 500$ - 200$= 300$.

Now, take another random sample, say, it is 400$ for Revenue, and 300$ for Expense. So, for the second round sampling, your profit will be 100$

Keep doing for many many times, (usually 10,000 times or more).

After taking thousands of samples, you can organize the sample data to a histogram, where, on the X-axis indicates a range of profit, and the Y-axis represents the number of random samples fell into that profit range.

From the above chart, you can understand that, out of 10,000 samples, 200 of them fell into the profit between 1,000$ to 2,000$. 300 of them fell into the range of 2,000$ to 4,000$ and so on.

As we get the total count for each profit range, we can get the probability of a range as :

sample count in a range/total samples (which is 10,000).

So, the probability of the profit range 1,000$ to 2,000$ is = 200/10,000 = 0.02. Finally, we can get the probability distribution of profit, like this:

This way of finding an ultimate probability distribution of a dependent random variable is called "Monte Carlo Simulation".

### Real Life Modeling Example

Lets model something for real. Say, you are planning for a vacation where you can go by car or by plane. If you go by car, your car can break down on the road and it may cost a variable amount of money. Also, you know that the cost of a plane ticket does not stay the same. It changes all the time. Assuming that you have learned how to create a decision tree using the Decision Tree software. Let's create a decision tree like this:

You are assuming that the probability of getting the car break down is 0.3. So, set the probability as shown in the above screenshot.

Now, let's create an objective "Minimize Cost". From the flyover menu of the "Go by car", click the "Payoff" button. If you did not create the objective yet, the objective creation wizard will start, like this. Select "Minimize" from the drop-down, and enter "Cost".

Then click "Proceed". You will be asked if the objective is a Subjective type, or Numeric type or Money type. You can select the "Money" type.

In the next screen, you will be asked, if you want to use interest rate based calculation. For this simple example, lets answer "No". Then, you will be asked about the minimum and maximum possible value of the variable "cost". Let's enter minimum = 0, and maximum = 1000.

Then, click Proceed. When you will be asked, if there are any more objectives to add, answer 'No', and then, you will be taken to the decision tree, like this.

Say, your cost for driving by car, can be anywhere from 100$ to 500$, because, you do not know how much would be the gas prices in various locations, how much food you may need to buy, etc. But, you can guess that most probably the cost will be close to 300$. The probability of the cost 500$ or 100$ is relatively low. Therefore, a normal distribution with a mean of 300$ can suit this scenario, right? Let's click the probability button as shown in the above screenshot. The probability distribution dialog will appear.

Once you select the normal distribution, you can specify the mean and standard deviation.

\

Click Ok, to accept the modeled probability distribution. The decision tree diagram will look like this.

Now, use a probability distribution for a Car break down the cost, which you are thinking, maybe within 400$ to 800$, and you do not have any clue about the most likely value. So, you can use a uniform probability distribution. According to the principle of indifference, if you have no reason to believe that one event will occur more likely than another event, then you can assume the same probability for all possible events. Therefore, according to that principle, as you cannot guess what kind of car break down may happen, you may use the continuous uniform distribution where the probability of each input is the same. So, same like the Car cost, attach a Uniform probability distribution that ranges from 400 to 800, like this:

And use another probability distribution for the Plane cost. You are assuming that the most likely value for a plane cost is 400$. But, it can be more or less, perhaps, 300$ to 700$. You may use a Triangular probability distribution or Normal Distribution, whatever you feel confident about. I think a triangular probability distribution may make sense, like this:

So, finally, the decision tree will look like this.

Ok, you have completed the modeling. Now, you can expand the Options analyzer panel to see all the calculated results. And guess what, the Monte Carlo Simulation is already performed for you. Just notice the probability distribution shown in the risk profile panel at the options analyzer, this probability distribution is the result of Monte Carlo Simulation.

Notice that, the probability distribution curve in the risk profile panel is not very smooth, because, by default, 500 random samples were used for the Monte Carlo simulation. You can change that to 10,000 to get a better result.

You can resize panels to get a better view of the results. As shown below. (Notice that, Stochastic Dominance is also calculated from the risk profile).

#### Explanation of the Result

Ok, the SpiceLogic Rational Will or Decision Tree Software has generated the Probability Distribution (In the Risk Profile panel). But How? The software, created thousands of random sample as follows:

1. A random sample is taken from the probability distribution of the "Go by Car" node. Say, that value is "p". Then, applying the probability wheel, from the chance node, an event node is selected based on the probabilities of the event node (i.e. 0.3 for the car break down). If the "Car breaks down" node was selected from the probability wheel of the chance node, a random sample is taken from the probability distribution of the "Car break down" cost. Say, that value is "q".

So, in the first round, the total cost is calculated as "p + q".

2. The same process continued for thousands of times and a lot of outcomes were calculated. The software decides to show 100 groups of data. Therefore, it creates a group interval for the total outcome such that, there will be a maximum of 100 groups. As you can see from the above screenshot, where the tooltip shows the group "-932.36 to -920.36" is a group of the outcome, and the probability of that group is 0.01.

### Options for Monte Carlo Simulation

By default, the Monte Carlo Simulation option is turned on for any scenario when a Probability Distribution is used.

You can turn off that behavior completely by setting the drop-down box selection to "Not Instantly" as you can see in the above screenshot. If you set to "Not Instantly", then, you will see a button to Execute the Monte Carlo Simulation so that you can manually execute the Monte Carlo Simulation whenever you wish.

If you set the option to "Always Instantly", then no matter if Probability Distribution is used or not, if there is at least a chance node in a decision tree, Monte Carlo simulation will be used to generate the Risk Profile.