程序代写 MIE1624H – Introduction to Data Science and Analytics Lecture 8 – Simulatio

Lead Research Scientist, Financial Risk Quantitative Research, SS&C Algorithmics Adjunct Professor, University of Toronto
MIE1624H – Introduction to Data Science and Analytics Lecture 8 – Simulation Modeling
University of Toronto March 8, 2022

Copyright By PowCoder代写 加微信 powcoder

Simulation Modeling

Sums of random variables
◼ For any random variable and a constant
◼ Expectation of the sum of two random variables is equal to the sum of expectations
and, therefore
◼ For the variance

Sums of random variables
◼ How to compute the probability distribution of the sum of random variables?
◼ We cannot add PDFs or PMFs
◼ The formula involves non- trivial integration and is known as convolution:
◼ Use simulation to evaluate such complex integrals

Sums of random variables

Simulation Modeling in Finance – Portfolio Selection

Financial portfolio simulation modeling – example 1
◼ We want to invest $1000 in the US stock market for 1 year:
◼ Invest into the S&P 500 market index (index fund)
◼ Value of investment at the end of year 1:
◼ Market return over the time period [0,1) is
◼ Generate scenarios for the market return over the year and compute ❑ decide on the number of scenarios and the set of scenarios for
❑ generate scenarios
✓ use historic scenarios
✓ draw randomly from historic scenarios (bootstrapping)
✓ draw random numbers from the assumed distribution (Monte Carlo)
❑ visualize and analyze the approximate probability distribution of
◼ In our example we assume that the return of the market over the next year follow Normal distribution

Financial portfolio simulation modeling – example 1
◼ Between 1977 and 2007, S&P 500 returned 8.79% per year on average with a
standard deviation of 14.65%
◼ Generate 100 scenarios for the market return over the next year (draw
100 random numbers from a Normal distribution with mean 8.79% and standard deviation of 14.65%):
◼ Compute and plot
Number of values
$ 1,087.90
Std Deviation
$ 1,118.96
$ 1,324.00
$ 1,458.52

Financial portfolio simulation modeling – example 1
600 700 800
900 1000 1100 1200 1300 1400 1500
Value at time 1
900 800 700
6000 0.1 0.2
0.3 0.4 0.5 Time
Simulated Value Paths

Why use simulation?
◼ Example 1 illustrates very basic Monte Carlo simulation system
◼ Simulation allows us to evaluate (approximately) a function of a random variable
❑ in example 1 the function is simple
❑ given distribution of , in some cases we can compute distribution of in closed form, e.g., if followed a Normal distribution, then also follows a Normal distribution with mean and standard deviation
❑ if was not Normally distributed, or if the output variable were a more complex function of the input variable , it would be difficult and practically impossible to derive the probability distribution of from the probability distribution of
◼ Other advantages of simulation:
❑ simulation enables visualizing probability distribution resulting from compounding
probability distributions of multiple input variables (example 2)
❑ simulation allows incorporating correlations between input variables (example 3)
❑ simulation is a low-cost tool for checking the effect of changing a strategy on an output variable of interest (example 4)
◼ Next, we extend example 1 to illustrate such situations 10

Financial portfolio simulation modeling – example 2
◼ You are planning for retirement and decide to invest in the market for the next 30 years (instead of only the next year as in example 1). Your initial capital is still
◼ Assume that every year your investment returns from investing into the
S&P 500 will follow a Normal distribution with the mean and standard deviation as in example 1.
◼ Value of investment after 30 years:
◼ The return over 30 years will depend on the realization of 30 random variables
◼ Observations:
❑ sum of Normal random variables is Normal
❑ here we have multiplication of Normal random variables, is it Normal?

Financial portfolio simulation modeling – example 2
◼ Between 1977 and 2007, S&P 500 returned 8.79% per year on average with a
standard deviation of 14.65%
◼ Simulate 30 columns of 100 observations each of single period returns:
◼ Compute and plot
Number of values
$ 12,587.62
Std Deviation
$ 10,948.39
$ 4,458.97
$ 2,655.55
$ 32,481.38
$194,355.00

Financial portfolio simulation modeling – example 2
00 2 4 6 8 10 12 14 Value after 30 years x 104
00 5 10 15 20 25 30 Time
12 10 8 6 4 2
Simulated Value Paths

Financial portfolio simulation modeling – example 3
◼ You are planning for retirement and decide to invest in the market for the next
30 years. Your initial capital is
◼ You have an opportunity to invest in stocks and Treasury bonds:
❑ allocate 50% of your capital to the stock market (S&P 500 index fund) today ❑ allocate 50% of your capital to bonds today
◼ Assume that every year your investment returns from investing into the
S&P 500 and Treasury bonds will follow a Normal distribution with the mean and standard deviation as in example 2 (for S&P 500), mean 4% and standard deviation 7% for bonds. Assume correlation -0.2 between the stock market and the Treasury bond market.
◼ Covariance matrix:
◼ Value of investment after 30 years: 14

Financial portfolio simulation modeling – example 3
◼ Simulate 30 years of 100 observations each of single period correlated returns:
◼ Compute and plot
Number of values
$ 7,892.80
Std Deviation
$ 5,233.10
$ 5,050.96
$ 2,951.82
$17,457.43
$ 1,408.63
$79,729.34

Financial portfolio simulation modeling – example 3
1200 1000 800
600 4 3 2 1
00 1 2 3 4 5 6 7 8
10 15 20 25 30 Time
Value after 30 years
Simulated Value Paths

Financial portfolio simulation modeling – example 4
◼ Using scenario generation procedure from example 3 for decision-making
◼ Compare portfolios:
❑ 50-50 portfolio allocation in stocks and bonds (Strategy A) ❑ 30-70 portfolio allocation in stocks and bonds (Strategy B)
◼ Compute and plot
Number of values
$ 1,865.13
Std Deviation
$ 2,214.87
$ 6,027.23
$-1,829.78
$45,972.08

Financial portfolio simulation modeling – example 4
-0.5 0 0.5 1 1.5 2 2.5 3 3.5
Value after 30 years

Simulation Modeling in Marketing – Marketing Campaign

Marketing campaign simulation modeling ◼ Case – marketing campaign
◼ Data – probability that client would buy a product ❑ 500,000 clients
❑ probability of buying a product for every client that is a result of another model ◼ Goal – find target group parameters to maximize profit

Marketing campaign simulation modeling
◼ Target function
◼ To compute profit we need information about sale income and contact cost
❑ Sale income is $10
❑ Contact cost is $2, it can be a distribution that we get from a more complex model for costs of contact, e.g., fixed cost plus variable cost based on duration of phone calls
◼ Our goal is
❑ maximize sales, i.e., number of clients that buy the product
❑ minimize cost of contacting each client, i.e., salary of client representatives
◼ Sales uplift – we choose a simple model of “uplift“, e.g., probability of sale will increase by 10% if a clients gets a call from the client representative
◼ Assume uniform distribution for the probability of sale
❑ if random number generated from uniform(0,1) distribution is < prob of sale for that client -> client would buy the product
❑ if random number generated from uniform(0,1) distribution is >= prob of sale for that client -> client would not buy the product

Marketing campaign simulation modeling
◼ Algorithm
1. Select target group parameters
(min_probability, max_probability)
2. Compute contact uplift (add 0.1 to probability)
3. Simulate sales using obtained probabilities
4. Calculate profit function
5. Repeat 100 times to get average values
6. Find the best target group parameters
◼ Final target group for contacting are clients with probabilities from 0.4 to 0.7
❑ clients with low probability would not buy product even after being contacted
❑ clients with high probability would buy the product without any additional stimulation

Simulation Modeling in Healthcare – Coronavirus Spread

Coronavirus spread simulation
Coronavirus spreads exponentially. How to “flatten the curve”?
◼ Four cases to simulate ❑ no measures
❑ forced quarantine
❑ social distancing (1/4 people move) ❑ social distancing (1/8 people move)
◼ Town of 200 people
❑ simulate people movements around the town
❑ if a healthy person comes into contact with a sick person, the healthy person becomes sick ❑ recovered person can neither transmit to a healthy person nor become sick again
❑ one person sick initially
◼ Three types of people ❑
Source: http://www.washingtonpost.com/graphics/2020/world/corona-simulator/

Coronavirus spread simulation – no measures
Source: http://www.washingtonpost.com/graphics/2020/world/corona-simulator/

Coronavirus spread simulation – forced quarantine
Source: http://www.washingtonpost.com/graphics/2020/world/corona-simulator/

Coronavirus spread simulation – social distancing (1/4 people move)
Source: http://www.washingtonpost.com/graphics/2020/world/corona-simulator/

Coronavirus spread simulation – social distancing (1/8 people move)
Source: http://www.washingtonpost.com/graphics/2020/world/corona-simulator/

Coronavirus spread simulation
Coronavirus spreads exponentially. How to “flatten the curve”?
Extensive social distancing!!!
Source: http://www.washingtonpost.com/graphics/2020/world/corona-simulator/

Coronavirus spread simulation
“Flattening the curve”
Source: https://www.visualcapitalist.com/infection-trajectory-flattening-the-covid19-curve/

Coronavirus spread simulation
“Flattening the curve”
Source: https://corona.katapult-magazin.de

Coronavirus spread simulation
“Flattening the curve – travel”
Source: https://www.3blue1brown.com

Simulation Modeling in Business – Restaurant Design

Business case study – optimal store design
Study environmental impact of restaurant operations
◼ Restaurant
❑ order types and probabilities
❑ processing times (fixed portion and variable portion) ❑ design alternatives
◼ Drive Through
❑ number of service windows ❑ queuing capacity
◼ Parking Lot
❑ parking capacity
❑ customer prioritization
❑ maximize customer satisfaction (high customer service level) ❑ minimize environmental impact (quantity of emissions)

Business case study – outline
▪ Introduction
– Problem description
– Restaurant operations model
▪ Problems with the standard design
▪ Analysis of the alternative designs
▪ Additions to the optimal design solution ▪ Additional extensions and policies
▪ Conclusions and recommendations

Problem description

Restaurant operations

Restaurant operations

Restaurant operations

Restaurant operations

Restaurant operations

Restaurant operations

Problems with the standard design
Most of the variable portion of the emissions are generated at the drive through lane
Customers should be encouraged to park their cars and enter the restaurant
Drive through customers should be served as fast as possible

Simulation results

Simulation results

Results – key indicatotrs
less than 12 minutes
waiting for
more than 1 minute to enter

Results – alternatives
Comparing 72 alternatives:
Limiting drive through to coffee/bakery orders Pull-off space for large drive through orders
2 or 3 service windows in drive through Customer prioritization: inside, outside or equal Varying queuing/parking capacity
3 outside layout #4 (6/19)
DErimveisDTsirihoCoirvnuoesuPtTgvPoahshsrum.r.kl2oelCi-n-urOugagPsfnhfCtrtdoiSaoFm3pro-iaeaotWcicrdzeiSantVytadaiaotorinswiefatDycetisoingn Data PointsDantad PEoffiinctisent Frontier
D r i v e t h r o u g h 3 l i m- Wi t e i n d d t
apacity #1 owDODisueatsbigildened
apacity #2 wEDnqaeubsaliegl dn
coffee/baked goods 2-Wind
Drive through serving
Capacity #4
everything
apacity #3 Inside
Emissions (kg/week)
CuCsutsotmomeresrastaistifsafcatciotinon(%(%) )

Results – optimal staffing
Original setup
Early shift
Night shift
0:00- 7:59
8:00- 15:59
16:00- 23:59
Weekday # staff available
Weekend # staff available
Optimal staffing
Early shift
Night shift
0:00- 7:59
8:00- 15:59
16:00- 23:59
❑ The staffing pattern has significant impact on the overall throughput
❑ Staff utilization is around 38%
❑ Introduction of more flexible shifts would result in 10-20% salary savings and virtually unchanged customer satisfaction and emission levels

Results – optimal staffing
Original setup
Early shift
Night shift
0:00- 7:59
8:00- 15:59
16:00- 23:59
Weekday # staff available
Weekend # staff available
Optimal staffing
Early shift
Night shift
0:00- 7:59
8:00- 15:59
16:00- 23:59
Customer satisfaction: 97.31% Customer satisfaction: 96.55% Emissions (kg/week): 41.39 Emissions (kg/week): 42.44

Results – parking capacities
Reducing the parking lot or drive through queue capacity may be required in case of constructing the restaurant on a small piece of property
Drive through queue size
Parking lot size
Customer satisfaction
The number of parking spots can be reduced from the original 19 to around 7-9
The number of spots in the drive through queue can be reduced to around 2-3 from the
original 6
Current arrival rates do not justify large parking capacities

Results – store layout
Kitchen size:
Kitchen size
Customer satisfaction
Emissions (kg/week)
Required: the space where at least 3-4 orders can be prepared simultaneously
Store waiting area size:
Required: space for at least 5-7 customers waiting to be served inside the restaurant

Results – effects of increased demand
❑ 10 kg/week reduction in greenhouse gas emissions translates into 5% increase in the number of customers
❑ Reduction for the proposed design is 17 kg/week
Increase in customer base
Customer satisfaction (%)
Total emissions (kg/week)
Increase in emissions over projected (%)
42.51 0.7%
43.69 1.5%
44.93 2.4%
46.02 3.0%
47.40 4.1%
❑ The store will be able to handle the increased demand while maintaining high customer service levels
❑ Gradually increasing staffing makes the proposed solution feasible over a long period of time

Additional extensions and policies
The “green” policy of the restaurant:
Make orders more expensive for the drive through customers
equivalent of introducing the emission sales tax and can be justified from the environmental point of view
Provide customers with the information about expected waiting times and greenhouse gas emissions per vehicle for the drive through lane and for using the parking lot
this information can be displayed on the illuminated indicator board (lighting panel) outside the restaurant
➢ make drive through more efficient or
➢ encourage customers to use parking lot instead

Recommendations
◼ We recommend implementing the following design:
➢ Drive through limited to coffee and baked goods
➢ Nopull-offspace
➢ Separatepayandpickupwindowsatthedrivethrough(3service
➢ Priority given to drive through customers (or equal priority if any
difficulties are expected with prioritizing the outside customers)
➢ Any reasonable parking lot/drive through design would work (it
depend more on the physical restrictions on the available space for the newly planned locations than on the other factors)
◼ Implement our additional recommendations about the staffing patterns and waiting area size as well as “green” policies

Optimal store design – conclusions
The optimal restaurant design:
➢ allows reducing greenhouse gas emissions by 30% while keeping customer satisfaction level virtually unchanged
➢ indirectly enforces “green” customer behavior
➢ is sustainable in the long run
➢ additional policies can enforce “green” customer behavior directly
❑ Problems:
➢ customers do not understand the problem of relatively high emissions while
using the drive through as compared to parking
➢ legal and financial restrictions may prevent implementing optimal “green” policy of the restaurant
➢ the staffing patterns are not 100% efficient and do not follow well changes in the customer arrival rates

Simulation Modeling in Business –
Traffic Simulation

Traffic simulation

Simulation Software

Simulation software

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com