Monte Carlo Simulation 101: Embracing Uncertainty in Data

jkrimmel_calculator_20150308I explain below, using a simple example, how Monte Carlo simulation works. I have included a link to an Excel file at the bottom of this post that shows all the calculations involved. The Monte Carlo approach offers a way to gracefully manage the uncertainty in data-driven challenges. For our complex world, it’s a way to simplify your problem without sacrificing what makes the problem interesting.

Posing the question

Let’s say we want to estimate how much fuel all the vehicles in the United States will consume annually through the year 2025. Fuel consumption depends on a lot of different factors, each of which may change independently of the others. It’s a complex scenario. Let’s use Monte Carlo simulation to embrace the uncertainty.

We need to make this simple. Let’s limit ourselves to just three factors that predominantly affect annual fuel consumption: (1) total number of vehicles, (2) average miles traveled annually per vehicle, and (3) average fuel efficiency. We will start with recorded data for 2012 and use it as a baseline to project annual fuel consumption through 2025.

Establishing a baseline

Fortunately the Bureau of Transportation Statistics, which belongs to the United States Department of Transportation, provides estimates for these quantities, again for 2012:

  • We had 253.6 million registered “highway” vehicles.
  • We had 4.274 trillion highway passenger-miles traveled. Let’s ignore the passenger implication and take this as total miles traveled. We can divide by the 253.6 million total vehicles to find that each vehicle traveled an average of 16,850 miles in 2012.
  • We had average fuel efficiency between 17.1 mpg (long wheel base) and 23.3 (short wheel base). Let’s just say it’s 20.2 mpg, the average of the two figures.

That’s where we’re going to start. Fuel consumption, in our simplified environment, equals total number of cars, multiplied by number of miles traveled annually per vehicle, divided by number of miles per gallon of fuel used (i.e. fuel efficiency).  Using that formula, we estimate 212 billion gallons of fuel were consumed by vehicles in the United States in 2012.

According to the EIA, 135 billion gallons of gasoline were consumed in the United States in 2013. Statista shows 2011 gasoline consumption of 131 billion gallons and diesel consumption of 40 billion gallons, for a total fuel consumption of 171 billion gallons. Our back of the envelope 212 billion gallon guess for 2012 doesn’t seem unreasonable. If there are more short wheel base vehicles on the road than long wheel base vehicles, the average fuel efficiency goes up, and our estimated fuel consumption would go down. But we’re in the ballpark here for our baseline.

Embracing uncertainty

Now we need to embrace the uncertainty. How do we expect each of these quantities to evolve? If we know what each of the three factors does in the future, we will know what happens to total fuel consumption. You can get into a lot of statistics here, but let’s keep it as simple as we reasonably can.

Let’s assume each factor varies by a certain percentage year-to-year. Take number of cars. We expect the number of cars to increase with time, but by how much? We can just make a reasonable guess here, by referring back to the Bureau of Transportation Statistics data to see how the total number of vehicles has evolved with time. From 2002 to 2012, the year-to-year change was between -2% and +3%. We can say that we expect the total number of vehicles to change by any amount in this range (-2% to +3%), with all values in the range being equally likely. In other words, the total vehicle count is just as likely to go down by 1% from year to year as it is to go up by 1%. It’s just an assumption we’ll make.

We can follow a similar path for the other two factors to estimate how much they will change from year-to-year. For miles traveled, ignoring a huge drop from 2008 to 2009 (presumably due to the Great Recession), we see changes between -2% and +2%. For fuel efficiency, we see changes between -3% and +3%, which is interesting because I would have expected a more uniform increase with time. This might be a parameter we would change in a “real” analysis, if we had solid reason to believe average fuel efficiencies would increase, on average, with time. Regardless, here we’ll stick with -3% to +3%.

Algorithmic implementation

I used Excel to perform the Monte Carlo calculations. You can use any tool you’d like, whether it’s a spreadsheet, a script-based programming language, an object-oriented programming language, or any other number of tools. The big idea is to use statistics to evolve each of the three factors (number of vehicles, distance traveled, and fuel efficiency) forward in time.

We start with 2012. We know the value we will use for each factor for this year. Now we need to estimate what will happen in 2013. I used the Excel RAND() function to randomly choose a value in the range we prescribed. Let’s take the total number of vehicles. We said that we expect that value to change between -2% and +3% from any one year to the next. I chose a random number between -2% and +3%, and changed the 2012 value by that amount. I did that 1,000 times, basically creating 1,000 different estimates for what the total vehicle count will be in 2013.

The 1,000 iterations is a central element of Monte Carlo simulation. It’s another way we embrace uncertainty. Rather than construct just one estimate for the total vehicle count in 2013, we create 1,000 estimates. Then we can use statistics to speak to how likely a particular change is. We know the average value will be a +0.5% change (splitting the difference between the -2% lower bound and the +3% upper bound). But now we can explore the variability around our average guess. What’s the vehicle count cut-off for the lowest 20% of our estimates? What’s the cut-off for the highest 20% of our estimates? We can use statistical analyses to speak to the variability in our estimate.

We don’t want to stop at 2013, though. We want to proceed through 2025. For each of our 1,000 estimates for the total vehicle count in 2013, we then estimate the count for 2014. We repeat the same process we used in going from 2012 to 2013. We take the 2013 value and change it randomly between -2% and +3%. That’s our 2014 total vehicle count estimate. We keep going with all of our 1,000 estimates, year by year, until we have 1,000 projected annual values through 2025.

But total vehicle count isn’t what we’re primarily interested in here. We want to know total fuel consumption. That means we need to follow the same procedure for the other factors (distance traveled and fuel efficiency). We will then have 1,000 estimates for each of the three factors for each year from 2012 through 2025. Given that data, we can compute the 1,000 estimates for total annual fuel consumption for each year (total number of vehicles multiplied by distance traveled per vehicle divided by fuel efficiency).

Results

The plot below shows our estimated annual fuel consumption for U.S. vehicles from 2012 through 2025. You’ll see we start at 212 billion gallons of fuel consumed in 2012. We expect this value to climb to 226 billion gallons by 2012, using the assumptions described above. This expected value is also called the “P-50 scenario”, meaning there’s a 50% chance the actual fuel consumption will be below this value (and thus also a 50% chance the actual fuel consumption is above our expected value). The plot also shows the P-20 and P-80 scenarios, meaning the cases where there are 20% and 80% chances, respectively, that the actual fuel consumption is below the indicated values.

monte_carlo_plot_jkrimmel_20150308

Next steps

If you wanted to make the analysis more complete, you could go several different routes, some of which are listed below.

  • Build a more robust 2012 baseline by studying the available data more deeply and adjusting the chosen values accordingly.
  • Include more factors that drive vehicle fuel consumption.
  • Broaden the analysis to explore other forms of transportation, including air and rail.
  • Use more realistic probability distributions, rather than the uniform distribution we use here. The normal distribution would be a clear next step and would require thought around best guesses for means and standard deviations.

Parting thoughts

I have used Monte Carlo simulation in two ways in the past. One was to study the lifting costs for heavy oil in Canada, where we had good information about the different component costs and wanted to understand how the uncertainty in each component translated to the total lifting cost. The other was to study how a particular market might evolve with time, and how our market share and revenue may respond to that evolution.

In both cases, we pushed past considerable uncertainty to propose and support a path forward. The greatest value from both efforts was simply having been deliberate in studying the problem. You can always debate the assumptions, the algorithmic details, the resulting visualizations, etc. But presenting a focused, rational attempt at problem solving goes a long way in attacking the natural fear around uncertainty.

You can find a link below to the Excel file I used to generate the results above. As always, if you have any questions, thoughts, criticisms, etc., feel free to either leave a comment on this post or email me at jeff at jkrimmel dot com.

Download: Excel file

One thought on “Monte Carlo Simulation 101: Embracing Uncertainty in Data

Leave a Reply

Your email address will not be published. Required fields are marked *