Conceptual Introduction Department of Veterinary and Animal - - PDF document

conceptual introduction
SMART_READER_LITE
LIVE PREVIEW

Conceptual Introduction Department of Veterinary and Animal - - PDF document

1/13/2020 Department of Veterinary and Animal Sciences Department of Veterinary and Animal Sciences Outline 1. Conceptual introduction 2. Simulating the Monty Hall Problem 3. Simulating in Herd Management Monte Carlo Simulation I 4.


slide-1
SLIDE 1

1/13/2020 1

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

Department of Veterinary and Animal Sciences Slide 2

Conceptual Introduction

Properties of methods for decision support

Department of Veterinary and Animal Sciences

SimHerd: Example of a commercial herd simulation model

Specific dairy herd simulations:

  • Milk yield
  • Feed usage
  • Reproduction
  • Disease prevalence
  • Death

Department of Veterinary and Animal Sciences

Used for decision making:

  • Investment decisions

(technology, wellfare, etc.)

  • Management deisions

Jan Tind Sørensen, Søren Østergaard, Anne Braad Kudahl, Jehan Ettema SimHerd: Example of a commercial herd simulation model

Department of Veterinary and Animal Sciences

slide-2
SLIDE 2

1/13/2020 2

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

Department of Veterinary and Animal Sciences Slide 7

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

Department of Veterinary and Animal Sciences Slide 8

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

Department of Veterinary and Animal Sciences Slide 9

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

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

Department of Veterinary and Animal Sciences

slide-3
SLIDE 3

1/13/2020 3

Variables and decisions are simulated with random number generation. Some possible random number generators are:

  • A coin
  • A dice
  • A computer

A random number generator for this simulation

Coin: Probabilities 0,2 0,4 0,6 0,8 1 1 2 Dice: Probabilities 0,2 0,4 0,6 0,8 1 1 2 3 4 5 6 Computer: Density 0,2 0,4 0,6 0,8 1 1,2 0,2 0,4 0,6 0,8 1

Uniform distribution

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

Department of Veterinary and Animal Sciences Slide 14

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

Department of Veterinary and Animal Sciences Slide 15

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

Department of Veterinary and Animal Sciences Slide 16

Simulation procedure IV Check whether Final guess = True

  • If yes:
  • Gain = 1000
  • If no:
  • Gain = 0

Simulation completed!

Department of Veterinary and Animal Sciences Slide 17

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.

Department of Veterinary and Animal Sciences Slide 18

slide-4
SLIDE 4

1/13/2020 4

Simulation procedure: Use computer

Exactly as before, except:

  • Instead of rolling the dice, we let the

computer draw a random number r.

  • 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)

Department of Veterinary and Animal Sciences Slide 19

Computer: Density 0,2 0,4 0,6 0,8 1 1,2 0,2 0,4 0,6 0,8 1

5-10 Minute Break

Purpose of simulation (formally) The purpose of a simulation usually is to calculate the expected utility, E(U(Θ, Φ)) , under a certain decision rule, Θ , applied to a system with a given state-of-nature, Φ. This problem may be very difficult (or impossible) to solve numerically. The correct solution might not seem immediately intuitive!

Department of Veterinary and Animal Sciences

(thetha, upper case) (phi, upper case)

The state of nature Let us take a look at the elements in the Monty Hall example:

  • The state of natue is:

Φ = (pt1, pt2, pc1, pc2) , where: pt1 = probability that door 1 holds the prize pt2 = probability that door 2 holds the prize Pc1 = probability that door 1 was the player’s first choice Pc2 = probability that door 2 was the player’s first choice A value could for instance be φ = (1/3, 1/3, 1/3, 1/3).

Department of Veterinary and Animal Sciences Slide 22

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!

Department of Veterinary and Animal Sciences Slide 23

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!

Department of Veterinary and Animal Sciences Slide 24

slide-5
SLIDE 5

1/13/2020 5

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!

Department of Veterinary and Animal Sciences Slide 25

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!

Department of Veterinary and Animal Sciences Slide 26

Simulating in Herd Management

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?

Department of Veterinary and Animal Sciences Slide 28

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.

Department of Veterinary and Animal Sciences Slide 29

Simple example, I

Department of Veterinary and Animal Sciences

slide-6
SLIDE 6

1/13/2020 6

Simple example, II

Evaluation of expected value of production

  • Deterministic:
  • Stochastic, known state of nature
  • Simulate 100 replications with µ = 10
  • Average: 439.9; Std. Dev. 18.9
  • Stochastic, unknown state of nature:
  • Draw 100 random values of µ from N(10, 1)
  • For each µ, simulate 100 replications
  • Average: 429.9, Std. Dev. 74.1

Department of Veterinary and Animal Sciences

– when both have Door 3 as their favorite door.

Simple example, III

Department of Veterinary and Animal Sciences

Representation of uncertainty of SON

Essential, but

  • Most simulation models ignore it

Adds uncertainty to the simulation Solution: have an extra step where state-

  • f-natures are drawn at random.

(as in the case study on Wednesday!)

Department of Veterinary and Animal Sciences Slide 33

Simulation procedure Select a number of alternative decision rules Θ to be tested. Draw n states of nature φ0

1, φ0 2, … , φ0 n from the

underlying distribution of state of nature p0(Φ0=φ0) For each decision rule:

  • For each state of nature, i:
  • Run the simulation model m times.
  • Calculate the average result Ui• over the m

simulation results.

  • Calculate the average value of U1•, U2•, … , Un•

Select the best performing decision rule.

Department of Veterinary and Animal Sciences Slide 34

Exercises: SimBatch

– when both have Door 3 as their favorite door.

Brief description – Modeling batch of slaughter pigs You are given

  • a model simulating the growth of a batch slaughter

weights, and given their state of nature

  • a dicision strategy for when the pigs are sent to

slaughter The given simulation model is determinstic

  • It is your job to make it stochastic!

Hints: probability distribution functions in R:

  • Normal: rnorm()
  • Uniform: runif()
  • Poisson: rpois()

Department of Veterinary and Animal Sciences