1/13/2020 Department of Veterinary and Animal Sciences Monte Carlo Simulation I Anders Ringgaard Kristensen and Dan Børge Jensen Department of Veterinary and Animal Sciences Outline 1. Conceptual introduction 2. Simulating the Monty Hall Problem 3. Simulating in Herd Management 4. Exercises: SimBatch Slide 2 Conceptual Introduction 1
1/13/2020 Department of Veterinary and Animal Sciences Properties of methods for decision support Department of Veterinary and Animal Sciences SimHerd: Example of a commercial herd simulation model Specific dairy herd simulations: Used for decision making: - Milk yield - Investment decisions (technology, wellfare, etc.) - Feed usage - Management deisions - Reproduction - Disease prevalence - Death Jan Tind Sørensen, Søren Østergaard, Anne Braad Kudahl, Jehan Ettema Department of Veterinary and Animal Sciences SimHerd: Example of a commercial herd simulation model 2
1/13/2020 Department of Veterinary and Animal Sciences But what is simulation? Simulation is an attempt to model a real world system in order to: • Obtain a better understanding of the system (including interactions) • Physiological models • Herd models • Study the effects of various (complex) decision strategies • Herd models Slide 7 Department of Veterinary and Animal Sciences Different kinds of simulation Randomness (cf. Chapter 14.3 in textbook) • Deterministic – forget it in herd management! • All calculations based on “average values” • Same input → Same output • System comprehension • Differential equations, physiology (NorFor). • “Probabilistic” models • All calculations based on distributions • Same input → Same output • System comprehension, decision strategies • Markov chains (earlier this course) • Stochastic (Monte Carlo) models • All random events are simulated by random number generation • Same input → Different output – i.e. we need many replications • System comprehension, decision strategies • Herd constraints, complexity Slide 8 Department of Veterinary and Animal Sciences Different kinds of simulation Hierarchy (levels) • Mechanistic: • A system is modeled by its elements (sub-systems) • A herd is modeled by its individual animals and their interactions. • Empirical • Only one level modeled • Output directly modeled from output Time • Dynamic • Static Slide 9 3
1/13/2020 Simulating the Monty Hall Problem The Monty Hall Problem - again Earlier we solved the decision problem by use of Bayesian networks and/or decision graphs. Alternative methods: • Experiment – many replications needed • Simulation – create a simulation model Department of Veterinary and Animal Sciences How to model the problem Identify the variables: • True placement, ”True” ∈ {1, 2, 3} • First choice, ”Choice 1” ∈ {1, 2, 3} • Door opened, ”Opened” ∈ {1, 2, 3} • Second choice, ”Choice 2” ∈ {Keep, Change} • Reward, ”Gain” ∈ {0, 1000} Define a decision strategy (2 options): • Choice 2 = Keep • Choice 2 = Change 4
1/13/2020 A random number generator for this simulation Variables and decisions are simulated with random number generation. Some possible random number generators are: • A coin Uniform • A dice distribution • A computer Coin: Probabilities Dice: Probabilities Computer: Density 1 1 1,2 1 0,8 0,8 0,8 0,6 0,6 0,6 0,4 0,4 0,4 0,2 0,2 0,2 0 0 0 1 2 1 2 3 4 5 6 0 0,2 0,4 0,6 0,8 1 Department of Veterinary and Animal Sciences Simulation procedure: Use dice Host must place the reward behind an arbitrarily selected door: • Roll the dice: • 1 or 2: Door 1 • 3 or 4: Door 2 • 5 or 6: Door 3 • Value of variable True determined as 1, 2 or 3 Participant must choose a door at random • Roll the dice: • 1 or 2: Door 1 • 3 or 4: Door 2 • 5 or 6: Door 3 • Value of variable Choice 1 determined as 1, 2 or 3 Slide 14 Department of Veterinary and Animal Sciences Simulation procedure II Check whether True = Choice 1 • If yes (two options): • Roll the dice (or toss a coin) • 1, 2 or 3: Open the lowest door number where i ≠ True • 4, 5 or 6: Open the highest door number where i ≠ True • If no (only 1 option): • Open door i ≠ True and i ≠ Choice 1 • Value of Opened determined Slide 15 5
1/13/2020 Department of Veterinary and Animal Sciences Simulation procedure III Value of Choice 2 determined in accordance with the decision strategy Define new variable Final guess ∈ {1, 2, 3} • If Choice 2 = Keep: • Final guess = Choice 1 • If Choice 2 = Change: • Final guess = i , where i ≠ Choice 1 and i ≠ Opened Slide 16 Department of Veterinary and Animal Sciences Simulation procedure IV Check whether Final guess = True • If yes: • Gain = 1000 • If no: • Gain = 0 Simulation completed! Slide 17 Department of Veterinary and Animal Sciences Evaluation of strategies Define the strategy as Choice 2 = Keep • Repeat the simulation many times (e.g. 1000) and calculate the average gain under the strategy. Define the strategy as Choice 2 = Change • Repeat the simulation many times (e.g. 1000) and calculate the average gain under the strategy. Compare the average gain under the two strategies and select the best. Slide 18 6
1/13/2020 Department of Veterinary and Animal Sciences Simulation procedure: Use computer Computer: Density 1,2 Exactly as before, except: 1 0,8 0,6 • Instead of rolling the dice, we let the 0,4 0,2 computer draw a random number r . 0 0 0,2 0,4 0,6 0,8 1 • Converting to variable value for True is done as follows: • If r < 0.33333: Door 1 • If 0.33333 < r < 0.66667: Door 2 • If r > 0.66667: Door 3 • (Similar for other variable values) Slide 19 5-10 Minute Break Department of Veterinary and Animal Sciences Purpose of simulation (formally) The purpose of a simulation usually is to calculate the expected utility, E( U ( Θ, Φ )) , under a certain decision rule, Θ (thetha, upper case) , applied to a system with a given state-of-nature, Φ. (phi, upper case) This problem may be very difficult (or impossible) to solve numerically. The correct solution might not seem immediately intuitive! 7
1/13/2020 Department of Veterinary and Animal Sciences The state of nature Let us take a look at the elements in the Monty Hall example: • The state of natue is: Φ = ( p t 1 , p t2 , p c 1 , p c 2 ) , where: p t 1 = probability that door 1 holds the prize p t2 = probability that door 2 holds the prize P c 1 = probability that door 1 was the player’s first choice P c 2 = probability that door 2 was the player’s first choice A value could for instance be φ = (1/3, 1/3, 1/3, 1/3). Slide 22 Department of Veterinary and Animal Sciences 7 minute mini-exercise! Download and open the quiz.R script 1. Take a moment to familiarize yourselves with the functions defined in the upper part of the script a. Where are random numbers generated? b. How are the random numbers generated? 2. Run the simulation with the two strategies at the bottom of the script a. What is the chance of winning with each of the strategies? 3. Keep the script open for the next few slides! Slide 23 Department of Veterinary and Animal Sciences State of nature, I In the example the state of nature has been • regarded as fixed and known Φ 0 = (1/3, 1/3, 1/3, 1/3) Assume that the host has a favorite door, e.g. door • 3. He places the reward behind Door 3 with probability 0.8 and behind each of the others with probability 0.1. The participant does not have a favorite door. • State of nature under those circumstances would be • Φ 0 = (0.1, 0.1, 1/3, 1/3) Does it change anything? Let’s try! • Slide 24 8
1/13/2020 Department of Veterinary and Animal Sciences State of nature, II Assume further that also the participant has a • favorite door, Door 3. He also selects (first choice) Door 3 with probability 0.8 and each of the others with probability 0.1. State of nature under those circumstances, – • when both have Door 3 as their favorite door, would be Φ 0 = (0.1, 0.1, 0.1, 0.1) Does it change anything? Let’s try! • Slide 25 Department of Veterinary and Animal Sciences State of nature, III Finally, assume that the participant has a • different favorite door, Door 1. He then selects (first choice) Door 1 with probability 0.8 and each of the others with probability 0.1. The host still prefers Door 3 as before. • State of nature under those circumstances • would then be Φ 0 = (0.1, 0.1, 0.8, 0.1) Does it change anything? Let’s try! • Slide 26 Simulating in Herd Management 9
1/13/2020 Department of Veterinary and Animal Sciences State of nature, IV In general, the optimal decision rule as well as the expected result depend on the state of nature. The state of nature in a livestock simulation model might be: • Average growth rate • Herd mortality rate • Average milk yield • … Is the true state of nature known (with certainty)? • Does it matter? Slide 28 Department of Veterinary and Animal Sciences State of nature, livestock models In livestock models we never know the true state of nature. We need to represent the uncertainty of the state of nature. We typically have some ideas – a belief in the true values. The belief may be represented as a statistical distribution. Slide 29 Department of Veterinary and Animal Sciences Simple example, I 10
Recommend
More recommend