Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use...

32
Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University of Phoenix * Apologies to GBS, 1902

Transcript of Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use...

Page 1: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Those who can, do; those who can't – use

Computer Simulation *

AMATYC S089 – Nov. 16, 2018Jerry Tuttle, FCAS

University of Phoenix

* Apologies to GBS, 1902

Presenter
Presentation Notes
Die graphic from https://pixabay.com/en/dice-games-play-1294902/ “Those who can, do. Those who can’t, teach.” Man and Superman. George Bernard Shaw. 1902
Page 2: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Background• Simulation is imitation to reproduce behavior of a

real-world system. • Useful for some problems when real-world is too

expensive, too dangerous, too complicated.

• Other non-mathematical examples?2

Presenter
Presentation Notes
CPR graphic from https://pixabay.com/en/cpr-dummy-medical-training-course-1255746/
Page 3: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Other non-mathematical examples

• Driving, flying training• Disaster preparedness• Science, engineering. Virus spreading• Role playing• Robotics. Biomechanics• Games• These are generally deterministic, not stochastic

3

Presenter
Presentation Notes
Driver simulator graphic from http://uniquenovelinterfaces.blogspot.com/2014/02/car-driving-simulator.html
Page 4: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Stochastic Simulation

• Stochastic simulation is sampling from a probability distribution to reproduce behavior of a system.

• Can help explain and illustrate difficult concepts.• Can solve problems that are hard or impossible to

solve directly.• Can be fun.

4

Presenter
Presentation Notes
Simulation graphic from https://www.hybris.com/medias/sys_master/root/h04/h0d/8814979711006/banner-factsheet-pricing-simulation.svg
Page 5: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Stochastic in Other Disciplines• Modelling the macro economy – inflation, interest

rates, govt spending, balance of trade, etc.• Modelling the longevity of Social Security, and

other insurance or business entities. • Stock market, retirement simulations.• Individual and team sports. Moneyball.• Project management, queuing.

5

Presenter
Presentation Notes
Baseball graphic from http://drspikecook.com/files/2012/11/sabermetrics-1xtkzx1.png
Page 6: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Simulation Process• Construct a model.• Design the experiment. • Generate random #s from prob distribution(s).• Analyze results.

6

Presenter
Presentation Notes
Tree graphic from http://www.clipartkid.com/if-you-have-any-questions-with-the-calendar-please-email-6qv4gI-clipart/
Page 7: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Nice Online Simulations• Rice Univ: onlinestatbook.com/stat_sim/index.html• Rossman/Chance:

rossmanchance.com/applets/index.html • Visualizing Statistics – UBC:

www.zoology.ubc.ca/~whitlock/kingfisher/KFhomepage.htm

• DIGMATH – Farmingdale State Coll: www.farmingdale.edu/faculty/sheldon-gordon/dynamicstatistics.shtml

• But – let’s build our own in Excel !7

Presenter
Presentation Notes
Excel graphic from https://play.google.com/store/apps/details?id=com.microsoft.office.excel
Page 8: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Generating Uniform Random #s• Common algorithm to generate pseudorandom #s

is xn = a*xn-1, mod m, for seed x0 and large m.• Here, xn/m is approx a uniform U(0,1) variable.• Excel has been criticized over insuff randomness,

and is now using Mersenne Twister algoritm whose cycle is Mersenne prime.

• = rand() is random # U(0,1).• =randbetween(min,max) : integer U(min,max)• =(b-a)*rand() + a is random # U(a,b)

8

Presenter
Presentation Notes
Melard, G. (Oct., 2014.) On the accuracy of statistical procedures in Microsoft Excel 2010. Computational Statistics. 29(5). 1095-1128. http://homepages.ulb.ac.be/~gmelard/rech/gmelard_csda23.pdf
Page 9: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

TI 84 & Random #s

• MATH → PRB• rand(): U(0,1)• randInt: U integer (min, max)• randNORM: N(μ, σ); not σ2.• randBIN: Binomial(n, p)• (b-a)*rand() + a: U(a,b)

9

Presenter
Presentation Notes
Calculator graphic from https://images-na.ssl-images-amazon.com/images/I/71RH7Vj8FUL._SY355_.jpg
Page 10: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Generating Non-Uniform Random #s

• A cumulative distribution function F(x) has inverse function F-1(z) in [0,1]. F can be discrete.

• If U is uniform random # in [0,1], then x = F-1(u) has cdf F.• =NORM.INV(prob, μ, σ) Also GAMMA.INV,

LOGNORM.INV 10

Presenter
Presentation Notes
Inverse function graphic from Herzog, T.N. (1986). Intro to stochastic simulation. Society of Actuaries.
Page 11: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Some Excel Examples• Definite integrals• Coin flip – run of 6 consecutive heads or tails• Birthday match; Monty Hall; Buffon’s needle• Sampling distribution• Central Limit Theorem, with Normal & skewed

populations• Confidence intervals• All Excel files available at

professortuttle.com/amatyc

11

Presenter
Presentation Notes
Page 12: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

12

• No simple anti-derivative exists from elem functions. (How do we know that?)

• Usually approximate such integrals with Riemann sums, Taylor series, others.

• If you can evaluate f(x) at any particular x value, you can approximate its definite integral with computer simulation.

Presenter
Presentation Notes
Reference: https://www.youtube.com/watch?v=8uBxLVvafx0
Page 13: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

13

• Simulate (x,y), count proportion of times that simulated y<f(x), multiply by rectangle area.• Here, xЄU(0,2), yЄU(min f,max f) =U(0,1). Area ≈ (1196/5000)*2 = .48• Similar problem approx π from circle.

Presenter
Presentation Notes
Reference: Garg University. Simple Monte Carlo to Integrate any Function in Excel. https://www.youtube.com/watch?v=8uBxLVvafx0
Page 14: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

14

Presenter
Presentation Notes
Page 15: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

15

Presenter
Presentation Notes
Page 16: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Excel Data Table

16

Presenter
Presentation Notes
Page 17: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

17

Presenter
Presentation Notes
Page 18: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

18

Presenter
Presentation Notes
Page 19: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

19

Presenter
Presentation Notes
Page 20: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

20

Presenter
Presentation Notes
Page 21: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

21

Presenter
Presentation Notes
Page 22: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

22

Presenter
Presentation Notes
Page 23: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

23

Presenter
Presentation Notes
Page 24: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

24

Presenter
Presentation Notes
Page 25: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Two Actuarial Problems

• Suppose I insure 50 insurance policies. • Each has avg frequency f = 1 claim/yr,

and avg claim size s = $60,000.• 1. What is 95th percentile of all claims?• 2. How much should I pay to lay off $1M

in excess of $3.5M to another insurer (reinsurer)?

25

Presenter
Presentation Notes
CAS graphic from http://www.casact.org/about/index.cfm?fa=contact
Page 26: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Convolutions• Problems 1 & 2 require we consider all possible

#s of claims & claim sizes, not just expecteds.• Ex: a. Suppose each policy may have either

0,1, or 2 claims; b. each claim is 50K, 60K, or 70K; and c. everything is equally likely.

• So the possibilities are 0 claims, 1 $50K claim, a $50K claim and a $60K claim, etc.

• List (convolute) all these possibilities and their probabilities. This is called aggregate claim distribution.

26

Page 27: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Aggregate claim distribution

27

• As number of possibilities increases, listing them becomes unwieldy.

• Would be nice to have formula pdfs f(x) for number of claim distribution & g(x) for claim size distributiion.

Presenter
Presentation Notes
The vertical axis is RELATIVE frequencies.
Page 28: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Few convolution formulas• There are many common pdfs, e.g., Poisson &

Negative binomial for number of claims, Gamma, Lognormal, Pareto for claim sizes. While some convolutions have nice formulas, e.g., Poisson with Gamma, most do not.

• Claim size pdfs in insurance need to be positively skewed (most claims are small, i.e., fender-benders vs. total loss).

• Now we are getting to the simulation.

28

Page 29: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Claim Size Simulation

• =NORM.INV(rand(),60K,40K)• =LOGNORM.INV(rand(),μ,σ), where here

μ=LN(60K)-.5LN[(40/60)2 + 1] = 3.91 & σ=√LN[(40/60)2 + 1] = .61 29

Page 30: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Simulation software result• Simulate count N, then simulate N claims.

Repeat 40K times, & sort aggregate claims.• Neg binomial freq M=50, SD=10; &

lognormal severity M=60K, SD=40K; 40K simulations:

30

Presenter
Presentation Notes
This did not come from Excel
Page 31: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Notes• Gordon, S.P. and Gordon F.S. (Jul/Aug

2009).Visualizing and understanding probability and statistics: graphical simulations using Excel. Problems, Resources, and Issues in Mathematics Undergraduate Studies,19 (4) 346-369.

• Herzog, T.N. (1986). Intro to stochastic simulation. Society of Actuaries.

• Melard, G. (Oct., 2014.) On the accuracy of statistical procedures in Microsoft Excel 2010.Computational Statistics. 29(5). 1095-1128. http://homepages.ulb.ac.be/~gmelard/rech/gmelard_csda23.pdf

• Ross, S.M. (2013). Simulation. San Diego: Academic Press.

• Verschuuren, G.M. (2016). 100 Excel VBA Simulations.

31

Page 32: Those who can, do; those who can't – use Computer …...Those who can, do; those who can't – use Computer Simulation * AMATYC S089 – Nov. 16, 2018 Jerry Tuttle, FCAS University

Images• Die graphic from https://pixabay.com/en/dice-games-play-1294902/ • CPR graphic from https://pixabay.com/en/cpr-dummy-medical-training-course-1255746/ • Driver simulator graphic from http://uniquenovelinterfaces.blogspot.com/2014/02/car-

driving-simulator.html• Simulation graphic from

https://www.hybris.com/medias/sys_master/root/h04/h0d/8814979711006/banner-factsheet-pricing-simulation.svg

• Baseball graphic from http://drspikecook.com/files/2012/11/sabermetrics-1xtkzx1.png• Tree graphic from http://www.clipartkid.com/if-you-have-any-questions-with-the-

calendar-please-email-6qv4gI-clipart/• Excel graphic from

https://play.google.com/store/apps/details?id=com.microsoft.office.excel • Calculator graphic from https://images-na.ssl-images-

amazon.com/images/I/71RH7Vj8FUL._SY355_.jpg • Inverse function graphic from Herzog, T.N. (1986). Intro to stochastic simulation. Society of

Actuaries. • CAS graphic from http://www.casact.org/about/index.cfm?fa=contact

32