Presentation is loading. Please wait.

Presentation is loading. Please wait.

Stochastic modelling and Monte Carlo Simulation Derek Karssenberg.

Similar presentations


Presentation on theme: "Stochastic modelling and Monte Carlo Simulation Derek Karssenberg."— Presentation transcript:

1 Stochastic modelling and Monte Carlo Simulation Derek Karssenberg

2 stochastic models Stochastic and deterministic models Deterministic model no ‘probabilities’ involved each time the model is run, the outcome is exactly the same example: LIFE, practicals: snow melt model Stochastic model includes probabilistic rules or stochastic variables each time the model is run, the outcome will be (slightly) different example: practicals: plant seed dispersal

3 stochastic models What is a probability? Example: a coin It is generally assumed that the probability for a head is 0.5: P(head) = 1/2 = 0.5 Note that a coin has two ‘equal’ sides, both with the same probability

4 what is probability What is a probability? Example: a die P(2) = 1/6 = 0.166666666 The probability of getting a 2 is 0.16666 Note that a die has six ‘equal’ sides, all with the same probability

5 what is probability Laplace definition with P(A)probability of A |A|number of points (outcomes) of A |S|total number of points (outcomes). i.e., the sample space Note that P(S) = 1

6 what is probability Laplace definition die:

7 what is probability What is probability: viewpoint of experiments We have a population of 180.000 people 60.000 people are smokers

8 what is probability What is probability: viewpoint of experiments In general: with P(A)probability that A occurs nnumber of experiments n A number of times that A occurred

9 what is a stochastic variable What is a stochastic (i.e., random) variable? A variable with a value depending on chance discrete stochastic variables (i.e. classified values) continuous stochastic variables (i.e. scalar values) Example of a discrete stochastic variable: a die The variable can have a value 1, 2, 3, 4, 5, or 6 The value depends on chance!

10 Probability function f of a discrete stochastic variable Gives the probability for each possible value

11 Probability function of a discrete stochastic variable Example: die

12 Cumulative distribution function F of a discrete stochastic variable

13 Probability function Cumulative distribution function

14 Probability function f of a continuous stochastic variable f(x) is a continous function, e.g. normal distribution f(x)

15 Probability function f of a continuous stochastic variable f(x) is a continous function, e.g. uniform

16 Cumulative distribution function F of a continuous stochastic variable

17 Probability function Cumulative distribution function

18 Cumulative distribution function F of a continuous stochastic variable Probability function Cumulative distribution function f(x) F(x)

19 Probability corresponding to an interval F(x) F(-2) F(-3)

20 Probability corresponding to an interval f(x)

21 what is a stochastic variable Stochastic variables, notation rules uppercase letterrandom variable lowercase letteroutcome (realization) of the random variable e.g., Z and z For instance, - a random variable has a certain probability distribution with a mean and a variance, while - the realization of it is a single value, e.g. 4.23123

22 stochastic variables in PCRaster Drawing a realization of a continuous stochastic variable Non spatial case (map of 1 cell!).. dynamic # draw a realization from a stochastic continuous variable, # with uniform distribution between 0 and 1 Value=uniform(Clone); report value.tss=timeoutput(Clone,Value);

23 stochastic variables in PCRaster Drawing a realization of a stochastic variable. dynamic # draw a realization from a stochastic continuous variable, # with uniform distribution between 0 and 1 Value=uniform(Clone); report value.tss=timeoutput(Clone,Value);

24 stochastic variables in PCRaster Drawing a realization of a discrete stochastic variable non spatial case... dynamic # draw a realization from a stochastic continuous variable, # with uniform distribution between 0 and 1 Value=uniform(Clone); # get a realization of a value of a stochastic discrete # variable, a dice outcome of 2 ATwo=Value lt (1/6); report value.tss=timeoutput(Clone,Value); report atwo.tss=timeoutput(Clone,ATwo);

25 stochastic variables in PCRaster Drawing a realization of a discrete stochastic variable non spatial case... dynamic # draw a realization from a stochastic continuous variable, # with uniform distribution between 0 and 1 Value=uniform(Clone); # get a realization of a value of a stochastic discrete # variable, a dice outcome of 2 ATwo=Value lt (1/6); report value.tss=timeoutput(Clone,Value); report atwo.tss=timeoutput(Clone,ATwo);

26 stochastic variables in PCRaster Drawing a realization of a stochastic variable spatial case script is the same, but realizations are drawn for each cell separately... dynamic # draw a realization from a stochastic continuous variable, # with uniform distribution between 0 and 1 Value=uniform(Clone); # get a realization of a value of a stochastic discrete # variable, a dice outcome of 2 ATwo=Value lt (1/6); report value.tss=timeoutput(Clone,Value); report atwo.tss=timeoutput(Clone,ATwo);

27 stochastic variables in PCRaster Drawing a realization of a stochastic variable spatial case... dynamic # draw a realization from a stochastic continuous variable, # with uniform distribution between 0 and 1 Value=uniform(Clone); # get a realization of a value of a stochastic discrete # variable, a dice outcome of 2 ATwo=Value lt (1/6); report value.tss=timeoutput(Clone,Value); report atwo.tss=timeoutput(Clone,ATwo);

28 stochastic variables in PCRaster Drawing a realization of a stochastic variable demo die aguila –2 Value00.001+20 ATwo0000.001+20

29 introduction Reasons for using stochasticity in a model 1) Many processes are difficult to describe with deterministic rules 2) Inputs and parameters are associated with uncertainty effect of this uncertainty on the model output can be calculated when these are represented by stochastic variables => error propagation modelling

30 forest fire model A simple forest fire model One boolean variable: TRUE (= fire) or FALSE (= not yet burning) Uses the Neumann neighborhood

31 forest fire model A simple forest fire model Transition rule: a cell catches fire with a probability P if at least one of its Neumann neighbors is burning else the state of the cell does not change

32 forest fire model A simple forest fire model.. initial Uniform=uniform(1); Fire=order(Uniform) lt 5; # starting points dynamic CellsNotBurningSurroundedByFire= (window4total(scalar(Fire)) gt 0) and not Fire; NewFire=CellsNotBurningSurroundedByFire and (uniform(Clone) lt P); Fire=Fire or NewFire;

33 forest fire model A more complicated forest fire model Demo forest_fire_part1 aguila –2 fire0000.001+1000

34 forest fire model A more complicated forest fire model Three possible states: 0no trees in cell (burnt down) 1trees in cell 2fire in cell Transition rules: a cell catches fire with a probability P if at least one of its Neumann neighbors is burning an empty cell sprouts trees with a probability F a burning tree burns down and becomes an empty site

35 forest fire model Clone=clone.map; TreeIni=ini.map; # 0, empty; 1, tree; 2, fire p=0.1; # prob. that an empty site sprouts a tree g=0.01; # immunity for fire probability timer 1 100 1; initial Uniform=uniform(1); Tree=if(Uniform lt 0.33,nominal(1),if(Uniform gt 0.66,2,0)); report TreeIni=Tree;...

36 forest fire model... dynamic report tree=lookupnominal(tree.tbl,Tree); # rule 1 NewSprouts=(uniform(1) lt p) and (Tree eq 0); # rule 2 Fire=Tree eq 2; NewFireClonal=(window4total(scalar(Fire)) gt 0) and (Tree eq 1) and (uniform(1) lt (1-g)); # rule 3 BurnDown=Tree eq 2; # combine rules Tree=if(NewSprouts,1,Tree); Tree=if(NewFireClonal,2,Tree); Tree=if(BurnDown,0,Tree);

37 forest fire model A more complicated forest fire model Demo forest_fire_part2 aguila –2 tree0000.001+1000

38 Error propagation modelling using Monte Carlo simulation Derek Karssenberg Utrecht University, the Netherlands

39 error propagation modelling Dynamic deterministic model zstate variables iinputs ffunctionals pparameters This is a deterministic model: - all inputs, parameters are exactly known - functional is deterministic (no probabilistic rules) Each time the model is run, it generates exactly the same output

40 error propagation modelling The problem of uncertainty If: i (inputs) are are not exactly known? e.g., amount of rain is between a and b or p (parameters) are not exactly known? e.g., saturated conductivity is on average a plus/minus b or f (functionals) use probabilistic rules? e.g. plant dispersal model Then: z is not exactly known either

41 error propagation modelling Dealing with uncertainty Represent inputs or parameters and variables as stochastic entities becomes: Zstate variables; stochastic variables, spatial) Iinputs; stochastic variables, spatial (or non-spatial) ffunctional Pparameters; stochastic variables, spatial (or non-spatial)

42 introduction Example model Rainfall (timeseries) Infiltration constant infiltration capacity parameter: KSat (mm/h) Runoff Manning equation (kinematic wave) parameter: n timestep: 10 seconds, cellsize 10 m

43 error propagation modelling Example model, deterministic version Rainfall (timeseries) Infiltration constant infiltration capacity parameter: KSat (mm/h) = 23 mm/h Runoff Manning equation (kinematic wave) parameter: n = 0.033 timestep: 10 seconds, cellsize 10 m CALCULATE HYDROGRAPH BY RUNNING THE MODEL ONCE

44 error propagation modelling Example model, stochastic version Keep everything the same, but represent saturated conductivity as a stochastic variable KSat (mm/h), stochastic variable (non-spatial, i.e. everywhere the same value): - probability distribution is normal - mean KSat = 23 mm/h - variance KSat = 3 mm/h WHAT IS THE HYDROGRAPH? HOW DO WE CALCULATE IT?

45 error propagation modelling one parameter (Ksat) is stochastic inputs are deterministic (most) variables become stochastic WHAT IS Z discharge (i.e., the HYDROGRAPH)? HOW DO WE CALCULATE IT?

46 error propagation modelling Monte Carlo approach for running a stochastic model Define a number of Monte Carlo loops N (e.g., N=1000) Three steps: 1)Generate N sets of realizations of each of the stochastic variables (inputs and parameters) 2)Run the dynamic model with each set of realizations (i.e., N times) and store the N outcomes 3)Calculate sample statistics of the N outcomes

47 error propagation modelling Example model, first step 1)Generate N sets of realizations of each of the stochastic variables (inputs and parameters) One stochastic variable KSat (mm/h): - probability distribution is normal - mean KSat = 23 mm/h - variance KSat = 3 mm/h 1st ‘set’, KSat = 22.2 2nd ‘set, KSat = 18.2 3rd ‘set’, KSat = 26.4. 1000nd ‘set’, KSat = 19.2

48 error propagation modelling Example model, second step 2)Run the dynamic model with each set of realizations (i.e., N times) and store the N outcomes 1st ‘set’, KSat = 22.2=> run model, store outcome: 2nd ‘set, KSat = 18.2=> run model, store outcome: 3rd ‘set’, KSat = 26.4=> run model, store outcome:. 1000nd ‘set’, KSat = 19.2=> run model, store outcome:

49 error propagation modelling Example model, second step hydrographs 3 hours discharge, m 3 / s

50 error propagation modelling Example model, third step 3)Calculate sample statistics of the N outcomes KSat = 22.2=> outcome: KSat = 18.2=> outcome: KSat = 26.4=> outcome:. KSat = 19.2=> outcome: For each time step calculate of the discharge the  average  standard deviation  median  quartiles  etc..

51 error propagation modelling Example model, third step 3 hours discharge, m 3 / s first quartile (25 th percentile) median (50 th percentile) third quartile (75 th percentile)

52 Example model, third step the outcome (statistics) represents Z discharge error propagation modelling 3 hours discharge, m 3 / s first quartile (25 th percentile) median (50 th percentile) third quartile (75 th percentile)

53 error propagation modelling In which cases is Monte Carlo simulation used 1.Error propagation modelling - inputs or parameters are measured and we know the error associated with these - represent these inputs or parameters as a stochastic variable - perform Monte Carlo simulation - result: model output with error bands

54 error propagation modelling In which cases is Monte Carlo simulation used 2.Global sensitivity analysis - assume certain variation in input parameter - represent this variation as a stochastic variable - perform Monte Carlo simulation - result: model output with its variation - variation represents sensitivity to the parameter under consideration

55 error propagation modelling In which cases is Monte Carlo simulation used 3.Probabilistic models - f includes stochastic rules (e.g. plant dispersal model) - perform Monte Carlo simulation - result: model output with its variation - variation represents ‘behaviour’ of the model


Download ppt "Stochastic modelling and Monte Carlo Simulation Derek Karssenberg."

Similar presentations


Ads by Google