Monte Carlo Simulations: The Intersection of Probabilistic and Deterministic
By: William Yee
Tags: Probability, Monte Carlo Method, Optimization, Determinism

Hi welcome to my blog, I hope you find this helpful as an introduction to Monte Carlo Simulations. What this is, a minimal mathematical approach to Monte Carlo Simulations with simple graphics to illustrate my various points. What this is not, a deep dive into Monte Carlo simulations for very specific and well defined industry problems.

This data and premise of this Monte Carlo Simulation comes from Coursera’s Advance Business Analytics course taught by the faculty at the University of Colorado. Originally, the calculation was performed on Analytic Solver, but I decided to bring the process into an environment that I’m (and hopefully you) more comfortable in, Python.

First, I used the words probabilistic and deterministic, I should define them in the context of this article.

Probabilistic: something that can be quantified by a probability distribution. E.G. How many people show up for their flight?

Deterministic: something that can be calculated from parameters. E.G. If 150 people show up for a flight that has 134 seats, how many people are bumped to the next flight?

A Monte Carlo Simulation can account for the uncertainty (probabilistic nature) in the parameters of a Deterministic model yielding a probability distribution of possible results.

The Problem

On any given flight, not all passengers complete the process to utilize their purchased seats. In response, airlines typically overbook flights to maximize occupied seats and revenue. However, if the overbooking rate is too high bumped passengers will have to reschedule flights and the overall reputation of the airline will be damaged.

Goals:

Determine an appropriate overbooking rate, using bumped passengers and revenue cost

Determine the revenue of any given flight

Givens:

Historical Data for this specific

Booking Capacity of Plane: 134 passengers

Price of ticket: 314USD

Cost to bump passenger: 400USD

At this point you maybe tempted to use the expected values of the historical data, or the max/min values, to calculate the expected values for overbooking rate, bumped passengers, and revenue. However, it is possible to have a distribution where the expected value is not a good approximation of the distribution. Such as something multimodal or something with heavy skew.

Both distributions have a mean of zero and a variance of 5

Both distributions have a mean of 1 and variance of 1

The Solution

To tackle this problem we need to break it into the follow steps.

Fit the distributions of the supplied historical data (Probabilistic Inputs) Build a mathematical model for flight overbooking process (Deterministic) Choose at random from the historical distributions, calculate the results, and repeat (Probabilistic Output)

Distribution Fitting of Historical Data

#############

###IMPORTS###

############# import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

import seaborn as sns

import fitter from scipy.stats import exponnorm , genlogistic

Import historical data to python using pandas and view a quick summary

hData = pd.read_csv('data/historicalData.csv')

hData.describe()

hData.shape

730 observations of 3 features, with zero missing data.

Flight Demand, Historical

Number of People that are Ready to Board, Historical

Let’s use the Fitter Package to model the distribution. Fitter uses 80 distributions from scipy to fit distributions and allows you to plot the results for a visual check.

f_demand = fitter.Fitter(hData.Demand, timeout= 100)

f_demand.fit()

f_demand.get_best() demand_params = list(f_demand.get_best().values())[0] f_shows = fitter.Fitter(hData.Shows, timeout =100)

f_shows.fit()

f_shows.get_best() shows_params = list(f_shows.get_best().values())[0]

The demand fitter output from f_demand.get_best() and f_shows.get_best() are presented below as a python dictionary. The best scipy distribution is the key and the parameters are the stored in the value tuple.

{'exponnorm': (0.4319945610366508, 145.53002093494484, 11.26683008052343)} {‘genlogistic’: (0.03148397254846405, 144.0118676463261, 0.3243429345277982)}

Mathematical Model