Simulation - public lecture

  • 211 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
211
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
2
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Simulation: an ubiquitous tool for statistical computation Simulation: an ubiquitous tool for statistical computation Christian P. Robert Universit´ Paris-Dauphine, IUF, & CREST e http://www.ceremade.dauphine.fr/~xian July 9, 2012
  • 2. Simulation: an ubiquitous tool for statistical computationOutlineSimulation, what’s that for?!Producing randomness by deterministic meansMonte Carlo principlesSimulated annealing
  • 3. Simulation: an ubiquitous tool for statistical computation Simulation, what’s that for?!Illustrations Necessity to “(re)produce chance” on a computer Evaluation of the behaviour of a complex system (network, computer program, queue, particle system, atmosphere, epidemics, economic actions, &tc) [ c Office of Oceanic and Atmospheric Research]
  • 4. Simulation: an ubiquitous tool for statistical computation Simulation, what’s that for?!Illustrations Necessity to “(re)produce chance” on a computer Production of changing landscapes, characters, behaviours in computer games and flight simulators [ c guides.ign.com]
  • 5. Simulation: an ubiquitous tool for statistical computation Simulation, what’s that for?!Illustrations Necessity to “(re)produce chance” on a computer Determine probabilistic properties of a new statistical procedure or under an unknown distribution [bootstrap] (left) Estimation of the cdf F from a normal sample of 100 points; (right) variation of this estimation over 200 normal samples
  • 6. Simulation: an ubiquitous tool for statistical computation Simulation, what’s that for?!Illustrations Necessity to “(re)produce chance” on a computer Validation of a probabilistic model Histogram of 103 variates from a distribution and fit by this distribution density
  • 7. Simulation: an ubiquitous tool for statistical computation Simulation, what’s that for?!Illustrations Necessity to “(re)produce chance” on a computer Approximation of a integral [ c my daughter’s math book]
  • 8. Simulation: an ubiquitous tool for statistical computation Simulation, what’s that for?!Illustrations Necessity to “(re)produce chance” on a computer Maximisation of a weakly regular function/likelihood [ c Dan Rice Sudoku blog]
  • 9. Simulation: an ubiquitous tool for statistical computation Simulation, what’s that for?!Illustrations Necessity to “(re)produce chance” on a computer Pricing of a complex financial product (exotic options) Simulation of a Garch(1,1) process and of its volatility (103 time units)
  • 10. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansPseudo-random generator Pivotal element/building block of simulation: always requires availability of uniform U (0, 1) random variables [ c MMP World]
  • 11. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansPseudo-random generator Pivotal element/building block of simulation: always requires availability of uniform U (0, 1) random variables 0.1333139 0.3026299 0.4342966 0.2395357 0.3223723 0.8531162 0.3921457 0.7625259 0.1701947 0.2816627 . . .
  • 12. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansPseudo-random generator Pivotal element/building block of simulation: always requires availability of uniform U (0, 1) random variables Definition (Pseudo-random generator) A pseudo-random generator is a deterministic function f from ]0, 1[ to ]0, 1[ such that, for any starting value u0 and any n, the sequence {u0 , f(u0 ), f(f(u0 )), . . . , f n (u0 )} behaves (statistically) like an iid U (0, 1) sequence
  • 13. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansPseudo-random generator Pivotal element/building block of simulation: always requires availability of uniform U (0, 1) random variables q 0.8 q q 0.6 xt+1 q 0.4 q q 0.2 q q q 0.0 0.0 0.2 0.4 0.6 0.8 10 steps (ut , ut+1 ) of a uniform generator
  • 14. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansPhilosophical foray ¡Paradox! While avoiding randomness, the deterministic sequence (u0 , u1 = f(u0 ), . . . , un = f(un−1 )) must resemble a random sequence! Debate on whether or not true randomness does exist (Laplace’s demon versus Schroedinger’s cat), in which case pseudo random generators are not random (von Neuman’s state of sin)
  • 15. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansPhilosophical foray ¡Paradox! While avoiding randomness, the deterministic sequence (u0 , u1 = f(u0 ), . . . , un = f(un−1 )) must resemble a random sequence! Debate on whether or not true randomness does exist (Laplace’s demon versus Schroedinger’s cat), in which case pseudo random generators are not random (von Neuman’s state of sin)
  • 16. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansPhilosophical foray ¡Paradox! While avoiding randomness, the deterministic sequence (u0 , u1 = f(u0 ), . . . , un = f(un−1 )) must resemble a random sequence! Debate on whether or not true randomness does exist (Laplace’s demon versus Schroedinger’s cat), in which case pseudo random generators are not random (von Neuman’s state of sin)
  • 17. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansPhilosophical foray ¡Paradox! While avoiding randomness, the deterministic sequence (u0 , u1 = f(u0 ), . . . , un = f(un−1 )) must resemble a random sequence! Debate on whether or not true randomness does exist (Laplace’s demon versus Schroedinger’s cat), in which case pseudo random generators are not random (von Neuman’s state of sin)
  • 18. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansTrue random generators Intel circuit producing “truly random” numbers: There is no reason physical generators should be “more” random than congruential (deterministic) pseudo-random generators, as those are valid generators, i.e. their distribution is exactly known (e.g., uniform) and, in the case of parallel generations, completely independent
  • 19. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansTrue random generators Intel generator satisfies all benchmarks of “randomness” maintained by NIST: Skepticism about physical devices, when compared with mathematical functions, because of (a) non-reproducibility and (b) instability of the device, which means that proven uniformity at time t does not induce uniformity at time t + 1
  • 20. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansA standard uniform generator The congruencial generator on {1, 2, . . . , M} f(x) = (ax + b) mod (M) has a period equal to M for proper choices of (a, b) and becomes a generator on ]0, 1[ when dividing by M + 1
  • 21. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansA standard uniform generator The congruencial generator on {1, 2, . . . , M} f(x) = (ax + b) mod (M) has a period equal to M for proper choices of (a, b) and becomes a generator on ]0, 1[ when dividing by M + 1 Example Take f(x) = (69069069x + 12345) mod (232 ) and produce ... 518974515 2498053016 1113825472 1109377984 ... i.e. ... 0.1208332 0.5816233 0.2593327 0.2582972 ...
  • 22. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansA standard uniform generator The congruencial generator on {1, 2, . . . , M} f(x) = (ax + b) mod (M) has a period equal to M for proper choices of (a, b) and becomes a generator on ]0, 1[ when dividing by M + 1
  • 23. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansA standard uniform generator The congruencial generator on {1, 2, . . . , M} f(x) = (ax + b) mod (M) has a period equal to M for proper choices of (a, b) and becomes a generator on ]0, 1[ when dividing by M + 1
  • 24. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansApproximating π My daughter’s pseudo-code: N=1000 π=0 ˆ for I=1,N do X=RDN(1), Y=RDN(1) if X2 + Y2 < 1 then π = π+1 ˆ ˆ end if end for return 4*ˆ /N π
  • 25. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansApproximating π pi = 3.2 q q q q My daughter’s pseudo-code: q q q q q q q q q q q q q N=1000 q q q q q q q q q qq q q q π=0 ˆ q q q q q q q qq q q q q q q for I=1,N do q q q q q q q q X=RDN(1), Y=RDN(1) q q q q q q q q q q if X2 + Y2 < 1 then q q q q q q qq q q q q q q q π = π+1 ˆ ˆ q q q q q q q q q qq end if q q q q q q q q q q end for return 4*ˆ /N π 100 simulations
  • 26. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansApproximating π pi = 3.108 q q q q q q q q qq q q qq q q qq q q q q q q q q q q q q q qq q qq q q q q q q qq q q q qq q q My daughter’s pseudo-code: q q q q q q qq q q q q q q q qq qq q q q q q q q q q q q q q q qq q q q q q q qq q q qq q q q q q q q q q q qq q q qq q q qqq q q q q q q q q q qq q q q q q q q q q qq q q q qq q q q q qq q q qq q q q q q q qq qq q q q q q q q N=1000 q q q q qq q q q qq q q qq q q q qq q q q q q q q q q q q q q q q q q qq q q q q q q q qq q q qq q qq q q qq q q q q q q qq qq q q q q q qq qq q q q q q q qq q q q q q q q q q q q q q q q q qq q qq qq qq q q q q q q qq q π=0 ˆ q q q q q q q q q qq qq q q qq q q q q q q q q qq q qq q q q q q q qq q q q q q q q q qqq q qq qq q q q q q q q q q q q q qq q q q q q q q q q qq q q q qq qq q q q q q q q q q q qq q q q q qq q q q q q qqq q q for I=1,N do q qq q qq q q q qq q q qqqq q q q q q q q q q q q q q q qq q q q q q q q qq q q q qq q q q qq qq q q q q qq q q q qq q qq q q q q q qq q qq q q q q q q q qq q q q q qq qq q q q qq q q qq qq q q q qq q q q q q qq q q q q q q q q q X=RDN(1), Y=RDN(1) q q q q q q q q q q q q qq q q q q q q q q qq q q q qq qq q q q q qq qq q q q q q q qq q qq q q q q qq qq q q q q q q qq q qq q q q qq q q qq q q q q q if X2 + Y2 < 1 then q q q qq q q qq q q q q q q q qq q q qq q q q q q qq q qqq q q q qq q q q q q qq qq q q q q q q q q q q q q q q q q qq q q q qq q qq q q q q q q q q q q q q qq q q q qq qq q q q q q qq q q qqq q q q q q q q q q q q qq q q q q q q q qq q q q qq q q q q q q π = π+1 ˆ ˆ q qq q q q q q q q q qq q q qq q q q q q q q qq q q q q q q q q q q qq q q qq q q q qq q q qq q qq q q q qq q q q q q q qq q qq q qq q q q q q q q q qq q qq q q q q q qq qq q q q q q qq q q q qq q q q q qq q q q q q q q q q q qq qq q qq end if q qq q q q q q q q q q q q q q q qq q q q q q qq q qq q q q q q qq q q qq q qq q q q qq q q q q qq q q q qq q q q q q q q q q q q qq q q q q q q q q qq q q q q qqq q q q qq q q end for return 4*ˆ /N π 1000 simulations
  • 27. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansApproximating π pi = 3.136 qqq q q q q q q q qq qq qq qq q q qq q qq q q q qqqq qq qq qq q q qqq q qq qqqq q qq q q qq qqq qq qq qqq q q q q q qq q q qqq qq q q qq qq q qq q q q q q q qq q q q q qq q qq q qq q q q q qq q q qq q q qq q qq qq q q qq q q q q qqq qq qq q q q q qq q q q qq qq q q qqq q q q q q q qq q qq q q q q q qq q q qq q qq q q q q qq q q q q q q qq q qq q qq q q q qq qq qq q qqqq qqqq q qqq qq q q qq q q qqq q q qq qqq q qqqqqq q qqqq q qqqq qq q qqqq qqqqq qq qq qqq qqq qqq qqqqq q qqqqqqq q q qqqq q q q qq q q q q q qqqq q qq q q qq q qqq qq qq qq q q q q q qq q qqqq q q q q q q q q q q qq qq q qq qq qqqq q q qqqqqq q qqq q qqq qqqq qq q qqq qqqqqq qqq qq q q qq qq qqq qqqq qq q q q q q qq q q q qqq qq q q q qqqqq q q qq q q qq q q q qq q q qq qq q qq q q qq q q q q q q q q qq qqqqq qqq q qqqqq qq q q qq q qqq qq q qq q q qq qq q q q q qq q q q q q qq q qq qq qqqqq qq qq qqqqqqqq qqqqq qqq qqqq qq q q qqqqqq qqqq q qqqqqqq qqqqq q q q q qqq q q q q qq q q q q qq q q q q q qq qq qqq qqqq q qqqq qq q q q q qq q q qq q q q q q q q q q q qq q q q q q q q q q q q qq q q q qq q qq q My daughter’s pseudo-code: qq qq q qq q q q qq qq q qqq q qq qq q q qq qq q qq q q q q q q q q q qq q qq qq qq q q qq q q q q qq q qq q q q q q qqq q q qq qq q qq qq q qq qq qq q q q q qq qqq qq qqq q q qq qqqq q qqqqqqq q q q q q q q q q q q q qq q q q q q q qqq q q q q q q q qq qq q q q q q q qq q q q q qq qqqqq qqqqqq q qqqqqq qq q q q qqq qq q q qqqq q qq qqq q q qq q q q q q qqq qqqq q qq qq q q qqq q q q q qqq qq q q qq qqqq q q q q q qqqq qqqq q q qq qq q q q qqqqqq qqqq qqqq q q q q q q q qq q q qq qq q qq q q q q qq qqq q qq qq qq q qq q qqq q qqqqq qq q q q q q q qqq q qq qq qq qq q q q qq qq q q q q q q q q qqq qqq q qq q q qq qq qq q q qqq q q q q q q qq q q qq q qq q qqq q q q q q q qq q q q q q q q qq q q q q q q q qq q q q qq q q q q q qq q q q qqq q qq q q q q q qqq q q qq q q q qq q q qq q q qq q q q q qq q q q qq qqqqqqq qq q q qq q q q qq qq q q q q q q qqqqq q qqqqq q qq qqq q q qqq q qq qqqqq qqqqqqqqqqqq q q qq qq q qqq qqqqqqqqq qq q q q qq q q q qq q q q q q q q q q q qq q qq q q q q qq q q q q q qqqqq q qq qq qqq qqqq qq qqqqqq q q qq q qqqq qqq qqqq q q q qqqq qq q q q q q qqq q q q q qq q q q q q qqq q q q q q q q q qqq q q qq q q qqq q qq q q q q q q qq qq q q qqq q q q q q q q qq q q qq q qq q q q qq qq qqq qq qq qq qqq q q q q q qqq q qq q q q q q q qq q q q q qqq q q q q q q qq q q qq qqqq qq q qq q q qq q qq q qq q q q q q q q q q qq qq q q q qqq q q qq q q q q q qq q q qqq qqq qqqqqq qqq q q q q q q q q qq qqq q q qq q q q qq q q qq q q q q qq q q q q q qq q q q q q q qq q q q qq qqq qq qqq qq qqqqq qq q q q q q qq q qq q q q qq qqqq qqq q q qqq qq q qqq q q q q q q qqqqq q qqq q qq q qq qqqq q qqqqq qq qq q qqqqqq qqqqqq q qqqqqqq q q qq q qqqq qq q q q qq qqqq qqq qq q q q q q q q q q qq q qq q qqq qq q q q q q q q qqq q qq qqq qqq q qq qqqqq qq q q q qq qq q q q q qq qqq q q q q q q N=1000 qq q q q qq qq q q qq qqq qq q q qq qq qqqq q q qq q q q q qq q q q q q q q q qq q qq q q q qqq q qq q qq qq q q q q qqq q qq qq q qq qq q q qq q qq qq q q qq q qqqq q q qq q qq q qq q q q q q q qq q q q qq q q q q q qq q q q q qqq q qq qq qqq qq q q q qq qq q q q q q q q q qq qq qqqqqqq q q qq qqqq qqqq q qqqqqqq qq qqq qqqqqqqq qqq qqq q qqq qqqqqq q q q qq qq q q qq qq qqqqq qq qqqq qq q q qq q qqqq q q q q qq q q qq q q qqqq q qq q qqq q qqq qq qq qqq q q q q q q q q q qq q q q q q q q q q qqq qqq q q qqqqq qqq q qqq q q qq qqqq qqqq qqqqq q qqqqq qq qqqqqqq q qqq q q q q q qq qqq q q q q q q qqq q q qqq qq q q qq q q qqqq q q qqq q q q q q qq q q q qq qq qq q q q qq q qq q qq q qqq q q q q q q qq qq q q q q q q q q q qqq q q q q q qq q qq q qq qq qqq q q qq q q q qq q qqqq qq q q q qqq q q q q qqq q qqq q qq q q qq q qq q qq qqq qqqqq q q qqqqqqqqq q q q qq qq q qq q q qqqqq qqqqqq q qqqqqqqqqq q qqqqqq qq q q q qqqq q qq q qqq q qqqq q q qqq q q qq q q q q q q qq q q qq q q q qq q q q q q q q q q qq qq q q qq q q qq qq qq q qq q q qq qqqq q qq qq qqq q q q q qq q q q q q q q q qq q q q q q q q q q q qq q qq q q q q qq q q qqq q q q q q qq q qqqq q q q qq qqq qq qq qq q qqq q q q q qq qqq qq q q q q qq q qq qq qq qqq qq qq qqqqqqq qq qqqqq qqq qqqqq q q qqq qq qq q qq q q q q q q qq qqq q qq q q qq q q qq q qq qqq q q q q qq q qq qq q q q q qq q q q qq q qqqq qq qq q q qq q q q q q qqq q qq qq q qq qq q qqq q qqqq qqqqq qq qqq q qq qqq qqq qq q qqq qqqq qqqqqq q q q qq q q qq qq qq q q q q q q qqq q q q q q qq qq q q q q q π=0 ˆ qq qq q q q qq q qq q q q q q q qq q qqq q qq q qq q q q qq q qq q qq qqqq q q qq qq qq q q q qq q q q q q q q q q qq q qq q q q qq q qq q q q q q qq q q q q qq qq qq qq qq q qq q qq qqqq q q qq qqq qqq q q qqq q qq q q qq q q q qqq q qqq q qqqqqqqqq q q q qqq qq qq qqqqqq qq qq qqq qqqqq q qqqqqq q qqqqq qqq qq q qq qq q q qq q qq q qq q qqq qqq q qqq qq q qqqqqqq q qqqqqqq qq q q q q qqq q qqqqq q qqq qq q q qq q q qq qqqqq q q qq q q qqqqqqqq q q q q q q q q q q q qq qq q qq qqq qqq q q qqq q q qq qq q qq q q q qq q q qq qqq qq q q q q qqqqq qqqqqq q qq q qqqq qqq qqqq q qq q qqqq q qq q qqq q qq q q q q qq qq q q qq qq qqqqqq q q qqq qqqqq q q qq qqq qqq q qq qqq qq q q qqqqq qqqq qq qq q qq qq q q q q q q qqqq qqq q q qq q q q q q q qq q q q qqq qq q q qq q q q q q q qq q q qq q qqqq qq q qqqqqq qq q qq qqqq qqqq q q qq q qqq qq qqq q q q qq q q q q qq q qq q q q q q qq q qq q qq q qqqq qq q q q qq qq q q q qq q q q qq qq q q q q q q q q q q q q q q q q qqq q qq q q q q q q qq q q qq q qq q q q q q qq qq q q q qqqq qq q q q q q q q qq q q qq q q q q q qq q qq q q q qq q qq qq qq q qq q q q q q qq q qq q q q qqqq q qqq q q q q q q q q q qqq q q qqq qqqq q qq q q qq q q q qqq qqqqq qqqqq q qqq qqqqq q q qqq q qq q q q q q q qq q qq qq qqq q q q qq q q qqq q qq q qq qq q q qq q q qq q q q q q q q q qq q q q q qq qqqqqqqqq q q qqqq q qq qq qq qqqq qqq qqqqqqqqq q qqqqq qqqqqqqq q q qq qqqqq q q q q q q q qqq qq q qq qqq q qq qqqqq qqqqqqq q qqq q q qqq qqq qq q qq q q qqq q q q q q q qqq q q q q qq q q qq q q q q qq q q q q q qq q q q for I=1,N do qqqqq qq qq q qqq q q qq q qqqqq q qqqq q q qq q qqq q q q qqqqq qqqqq q qqqqq q qq qq q q qqq q q q q q qqqqq q q q q qq q q qq qq q qq qq q qq qq q q qqqq qq q qq q qq qqq qq q q q q q q qqq q qqq qq q qqqq q q qqq qqq q q q qq qq q q q q qq q qq q q qqqq q q q qqq q q q q qq qqq qq qq q q q q qq qqq q qq q qq q q qq q q qq q q q q q qq q qq q qqqq q q q q q q q q q q q q qq qqq q q q q qq q q q q qq q q q qq qq q q qqqqqq q qq q qq qqq q q q qq qq q qq q q qqqqqq qq q qq qqq qqq qqq q q qq q q qq q qq q q q q q qq q q q q qq q qq q q q qq qq q q qq q q q qq q q q q qq q q q q qq q q qq q qq q q q q q qqq qq q q q q q qq q qqq qq q qqq q q q qqq qqq qqq q q qqqqqqq qqqqq q q qqq qqq q q qq q q q q q q q q q qq q qqq q q q qq qq qq q q qq q q q q qq q qqq qq q q qqqqqq q qq qqq q q qq q qq qq q q qqqqqqqqqqq q qqqqqqqqqqqq q q q q q q q q q qqqq qq qq q q qqqq qq q q q q qq qq qq q q qq q qq qq qq q qqq qq qqqqqq q qq qqqq qqqq q qq q q q q q q q qq qqq q qqq q qq q q qqqq q qqqq qqqqqq qqqq q q q q q q qq q q q q q q q qq qqq q q q q qqq q qqq q q qqq q qq qq qq q q q q qq qq q qq q q q q q q qq q q q qq qq qq qq q q q q q qq q q qq q q qq q q q q qq qq qq q qq q q q q q q qq q q qq qq qq q q qq q q qq q q qqq q q q qqq q q qqqq q q q qqqqq qqqq qq qqqqq q q qqqqqqqq qqqq q q qq q q qqqqqqq qqq q qq q qqq q qq qqq qqqqqq qqq q q q q qqqq qqq qqqqq qq qq q qq qq qq q q q q q q q qq q q q q q q q q qq q qqq q q q qq q qq q qq q qqqq qqqqqq qq qq qq qqqq qqq q qq qqq qqqqq qqq q q qq qqq qqqq qqqqqqq q q q q q qq q q q q q q q q q qq q q qq q qq q qq q q qq q qq q q q q qq q q q q qq q q qq q q q q q q q q q q qqq q q q qq q q q qqq q qqq q q q q qqq qq qq qq qqqqq qq q q q q X=RDN(1), Y=RDN(1) q q q qq qqq qqqqq qq qqqq qq qqqqq qqqqqq qq qqq qqq qqq qq qq qqq qqq qq q qqqq q qqqq qq q q q qq qq q qq q q qq qqq qqq q q qqq q qq qqqqqq qqq qq q q q q q qqq q qq q q q qq q q q q qq q q q q q q q q qq q q qq q qqqqqq q qqq qqqq q q q q qq qqq qq q q q q qq q qq q qq qq q q q q q qq q q q q q qq q qq q q q qqq q qq q q q q q q qq q q q qq q q qq qq qq qq q qq qq q q q q q q qqq qq q q q q q qq q qq q q qq qq qqq q q q qqq qqq qqqq qq qq q q q qqqq q qq q q q q q q q q q q q q qq q q q qq qqq qqq q q q q qqqq qq q q qqqq q q qqq q qqqq q q qqqqqqq q qq q q qqq q qqq qq q q q q qq qq qqq q q q qqqqqqq qq q qq qqqq q qq q q q qq q qqq qqq q q qq q q q q q qqq q q q q qq q q q q q qqqqq qq q q q qq q qqq q q q qq q q q q q q q q qq qq q qqq q qq qq q q qq qqq q qq qqqqq q q q qq q qq q qqq q qqqq q qqq q qqq q qq qqqq qq q q qq q q qqq q qq q q q q qqq q qq qq q q qqqq qq qq qqqqqq qq q qq q qqqq qq q qqqqq q qq qq q qq qqqq qq qqqq q q q qqqq qq qqq q q q qq qq q q q q qq q qq q q q qq q q q q q qq qq q qq qq qq q qq q q q q qqq q q q q qq q q q q qq qq q q q q q qq qq q q q q q q q q qq q q q qq q q q q q q q q q qqq qq q q qq q q q q q q q q qq q qq q qqqqqq q qqqq q qqqqqq qq q qqqq qqqqqq q qqqqqqq q qq qqq q qqqq qqq qqqqqq q qq if X2 + Y2 < 1 then q q q q q qqqq q q q qq qqq qqqq q q qqq qqqq q qqq qqq q q qqqq q q qq qq q q q qq q qq q qq q q q q qq qqq q q q q qqq q q q qq qqqq qqqq q q qq q q q qq q qq q q q qq q q q qq qq qq qq q q q q q q qq q q q q q qq q q q q q qq q q q qqqqq qq qq q q q qqq qqqqqq qqqqqqqq q qqqqq q q q qqq qqqq q qqq qqq q q qqqq qqq qqq q qq q qq q q q qqq q qq qqq qqqq q q qqqq q qqqqq q q qqqqqqqqqqq q qq qqq qqqq qqq qqq q q qqqqqq qq q qq qqq q q q q qqq q qq q q q qq q qq q qqqqqqq q q qq q qqq q qq qqq qqqqq qq q q qq q qq qq qqqqq qqqq qq q q qq q q q qq qq q qq qqqqqq q qqqqqq qq qq q qq q q q q q q q qq q q q q q q q q q q q qq qq q qq q q qqqqq qqq q q q q qq q q q qqq q q qqqqqq q q q qq qq q q qqqq q q q q q qqqq q q q q q q q q qq q qqqqq q q q qq q qq q q q q q q q q q qqq q q q q qq q q q q q q qq q q qq q q qq q qqq qq qq q q q q q qqq q qq qq qq qq qq q qqq qqqqq qqqqqqq qqq q q qqq q q qqqqqq qq q qq qq q qq q q q qq q q qq qqq q q q q q qq qq q qq qq q q q q qqq q q q qq q q q q q q q q q q qq q q q q q q qq q qq q q q qq qq q qq q q q qqqqqq q qq q qqqqqqq q q q q q qqq qqqqqq qqq q q qqq qq q qq qq q qqqq q q q q q qq q q q qq qqq qq q q q q q q qqq q qqqq q qq qq q q qqq qq q q q qq q qq q qq q q q q q q q q q qq q q q q q q qq q q q q q q q qq q qq q qqq q q q q q qqq q q q q q qqq q qqq qq q q qq q qq q q qqq qq qq q qq q q qq qq q q qqq qqqqqqqqqq q qq qq qqq qqqq qqqq qq q q qqqqqqqq q q qq q qqq q q q qq q q q qq q qq qqq q q q qq q q q q q q q qq q q q q qq q q q q q q qq q q qq q qqqqq qqqq qqq qqq qqq qqq qqqq qq qq qqq q q qq q qqq q q q qq qq q qqqq qq q q q qq q q qqq q qqqq q q q q q qqq qq qq q qq q q qq qq q q q q q qq q q qq q q q q qqqq q q qq qq q q q q q q q q q q qqq q qq q qq q qq q q q q q qq q qq qq qq q q qq q qq q qqq qq qq q qqq qq qq q qq qqq q qq q qqq qqqqq q qqq q q q q q qqq q qqq q qq q qq q q q q q qq q qq π = π+1 ˆ ˆ q qq q q qq q q qq q qq q qqq q q qq q qqq qq q q q q q q q qq qq q qqqq qq qqq q qq q q qq q q q qqqqqq q q q q q qqqqqq qq q qq q q q q q qqq qqqq q qqq q q q q qq qqqq qq qq q qq q q q q q qq q q q qq qqq qq qq q q q qq qqq q q q qq q qqq q q q qq qq q qq q q q q q qq qq q q q q qq q qqq q qq qq q q qq q qq q q q q q q qq qq q q q q q q q qq q qq qqqqq q q qq qqqq qq q q qqq q qq q q q q q q q qqq qqqq qqq qq qq q qqq qq q q q q q qqq qqqqqqqq q qqqq qq qqqqq qqqq qqqqq qq qqqq qq qqqq qq qqq q q qqqqqq qq q q qq q q qq qq qqq q qq q qq q q q q qq qq q q q q qq q qq q q q qq q qqqq q q qqqqqqq qqq q qqqq qqqq q qqq q qq qqq q qqq q qq qq q qqq q q qq q q q qq q qq qq q q qq q q q qq q q qq qqq q qq q q qq q q q qq q q qq qq q qqq q q q q q q q qq q q q qq qq q qq qq q q qq q q qq qq q q q q q q q q q q q qq qq q q q q qq q q q q q q q q qq q q qqq q q q q q qqqq q q q q q qq qq q qq q q q qq q qq qq q q qqq q q q q q qqq q q q q qqq q q q qq qq q q q q q qq qq q q q q qqqqqqqqqqq q qqqq q qqq qqqqq qqqqq qqqqq qqq qq q q qq q q qqq qqqq qqq qqq q q q q q q q qq qq qq qq qq qq qqq q q q q qqqq q qq qqqqqq qqqq q q q q q qqq q q q qq q q qq q q qqqq q q q q q q q q q qq qqq qq q q q qqq qq q q qq q q q qq qq q qq q q qqq qq qq q q q q q q qqq qq qqq q q q qq q q q q q qq qq qq q q q qqq q q q q q q q q q q q q q q q qq qqqqq q q qqq q qqq q q qqqq q qqq q qq q q q q qqq qqqqq q q q q qq q q q qq q q qq q q q q qq q q qq q qq q q q q q q q q qq qq q q q q q q qq qqq q qqqq q q qqqqq q qqq qq q qq q q qqqqq qqqq q qq qqqqqqqqqqq qq q qq qq qq q qq q q q qq q q qq q q q q end if q q q qq q qq q qqq q q q q q qq qq qq q q qqq q q q qq q qq q q q q qq q q q q qq q qqq q q qq q q q qq qq q q q q qq q q q qq q q qq q q q q qq q q qqq q qqq q q q qq q q qqq q q qqqqq qq q qq qqqq qqqq q qq q qqq q q q q q q q q q q q q qqq qq qq qqq q q q qq q q q q q q q qq qq qq qq qqqqq q qqq q q qq q q qqqq q q qq qqqqqq q qq q q qqq qqq q q q q qq q q q qqqq q q q q q q q qq q q q q q q qq q q qq q q q q q qq q q qq q q q q qqqq q qq q qqq qq q qq qqq q qq q q qqq q q q q q q q q q q q qq q q q qq q q q q q q q q qq q qq qq q q q q qq qq q q q q q q q q q q q qq q q q qq q qqq q q qqq q q q q qq q q q qq q q q q qq q qq q qq q q qq q q q q qqqqqq q qqqqq q qq q qqqqq qqq qqq q q q q q qqqq q qqqqqq qq qqq qqqqq qq qq q qq q q qq q q qq q q q q q q q qq qq q q q qq qq qqq q q q qq qq qqq qqq qqq qqqq q q qq qq q q qqqqq qq qq qq q q qqq qqqqqq qqq qq q q qq q qq q q q q q qq q q qqqq qq qqqq q q q q qqqq qqqq qqqqq qqq qqqqqqqqqq qqqqqq q qqq qq q qqqq q q qqqqq qq q q q qq q q q q qq qqq q q q q q q q q qq qqq q q q qq q q q qqq qq q qqqqq qqq q qqqq qq q qq qq qqqqq qq q qq qqq q q q q q qq q qq q q qqq qq qq qq q qqq q q q q q q q qqq qq q qq q q q q q q q q q q q q q q qqq q q q q q q qq qq q q q q q q q q q qq qq q q qqq q q q q end for return 4*ˆ /N π 10,000 simulations
  • 28. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansApproximating π My daughter’s pseudo-code: N=1000 π=0 ˆ for I=1,N do X=RDN(1), Y=RDN(1) if X2 + Y2 < 1 then π = π+1 ˆ ˆ end if end for return 4*ˆ /N π 106 simulations
  • 29. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansDistributions that differ from uniform distributions Proble Given a probability distribution with density f , how can we produce randomness according to f ?! f (x) implemented algorithms in a resident software only available for common distributions new distributions may require fast resolution x no approximation allowed an arbitrary density
  • 30. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansDistributions that differ from uniform distributions Proble Given a probability distribution with density f , how can we produce randomness according to f ?! f (x) implemented algorithms in a resident software only available for common distributions new distributions may require fast resolution x no approximation allowed an arbitrary density
  • 31. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansThe Accept-Reject Algorithm (remember π?!) Given a probability distribution with density f , how can we produce randomness according to f ?! The uniform distribution on the sub-graph region Sf = {(x, u); 0 ≤ u ≤ f (x)} produces a marginal distribution f (x) in x with density f . (”Fundamental theorem of simulation”) x
  • 32. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansThe Accept-Reject Algorithm (remember π?!) Given a probability distribution with density f , how can we produce randomness according to f ?! q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q In practice, this means we are q q q q q q q q q q q q q q back to throwing dots on a box q q q q q q q q q q q q q q q q q containing q q q q q f (x) q q q q q q q q q q q q q q q q Sf = {(x, u); 0 ≤ u ≤ f (x)} q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q and counting those inside! q q q q q q q q q q q q q q q q q q q q q q q q q q q q q x
  • 33. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansThe Accept-Reject Algorithm Refinement of the above through construction of a proper box: 1. Find a hat on f , i.e. a density g that can be simulated and such that sup f (x) g (x) = M < ∞ x 2. Generate dots on the subgraph of g , i.e. Y1 , Y2 , . . . ∼ g , and U1 , U2 , . . . ∼ U ([0, 1]) 3. Accept only the Yk ’s such that Uk ≤ f (Yk )/Mg (Yk )
  • 34. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansThe Accept-Reject Algorithm Refinement of the above through construction of a proper box: 1. Find a hat on f , i.e. a density g that can be simulated and such that sup f (x) g (x) = M < ∞ x 2. Generate dots on the subgraph of g , i.e. Y1 , Y2 , . . . ∼ g , and U1 , U2 , . . . ∼ U ([0, 1]) 3. Accept only the Yk ’s such that Uk ≤ f (Yk )/Mg (Yk )
  • 35. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansThe Accept-Reject Algorithm Refinement of the above through construction of a proper box: 1. Find a hat on f , i.e. a density g that can be simulated and such that sup f (x) g (x) = M < ∞ x 2. Generate dots on the subgraph of g , i.e. Y1 , Y2 , . . . ∼ g , and U1 , U2 , . . . ∼ U ([0, 1]) 3. Accept only the Yk ’s such that Uk ≤ f (Yk )/Mg (Yk )
  • 36. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansThe Accept-Reject Algorithm Refinement of the above through construction of a proper box: q qq q q qq q q q qq q q q q q qq q q q q q q q qq q q q q q q qq q q q q qq qq qq q q q q q q q qq q q q qq q q q q q q q q q q q qq q q q q q q q q q q q q q q q qq q q q qqq q q q q q q q q q q q q q q q qq q q q qq q q q q qq q q q q qq q q q q q q q q qq q q q q qqq qq q q q q q q q q q qq q q q qq q q q q q q qqq q q q q q q q q q q q q q qq q q q q q qq q q q q q q q q qqq q q q q q q q q q q q q q q q q q q q q q q q qq q q q q qq q q q q q q qq qq q q qq q q q q q q q q qq q q qq qq q q q q q q q q q q q q q q q q qq q qq q q q q q q q q q q q qq q q q q q q q qq q qq q q qq q qq q q qq q q q qq qq q q q q q q q q q q q f (x) q q q q q q q q q q qqq q q q qq q qq q q q q q q qq q q q q q q q q qq q q qq q q q q qq q q q q q q q q q q q q q q q q q q q q q q q qq qq q q q q qq q q q qq q q q q q q qq q q q q qq q q q qq q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q qq q q q q q qq qq q qq qq q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qqq q q qq q q q q q q q q q q q q q qq q q q q q q q qq q q qq q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q qq q q qq q q q q q q q q qq qq q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q qq qq q q q q q q q qq q q q q qq q qq q q q q q q q qqq q q qq q q q q qq q q q q q q qq q q q q q q q q q q q q qq q q q q q q q q q qq q q q q q q q qq q qq q q q q q qqq q q q q q q qq q q q q q q q q qq q q q q qq q q q q q q q q q q q q q q q q q q qq q q q q q qq q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q qq q q q qq q q q q q qq q q qq q q q q q q q q qq q q q q q q q q qq q q q q qq q q q q q qq q q q q q q q q q q q q q q q q q qq q q qq q q q q q q qq q q q q qq q qq q q q q q q q q q q q q q q q q q qq q qqq qq q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q qq q q q q q q q q q x
  • 37. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansProperties Does not require normalisation constant of f Does not require an exact upper bound M Requires on average M Yk ’s for one simulated X (efficiency measure)
  • 38. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansProperties Does not require normalisation constant of f Does not require an exact upper bound M Requires on average M Yk ’s for one simulated X (efficiency measure)
  • 39. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansProperties Does not require normalisation constant of f Does not require an exact upper bound M Requires on average M Yk ’s for one simulated X (efficiency measure)
  • 40. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansSlice sampler There exists other ways of exploitating the fundamental idea of simulation over the subgraph:
  • 41. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansSlice sampler There exists other ways of exploitating the fundamental idea of simulation over the subgraph: If direct uniform simulation on Sf = {(u, x); 0 ≤ u ≤ f (x)} is too complex [because of unavailable hat] use instead a random walk on Sf :
  • 42. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansSlice sampler There exists other ways of exploitating the fundamental idea of simulation over the subgraph: this means doing random jumps in vertical then horizontal direction, accounting for the boundaries 0 ≤ u ≤ f (x), i.e. U(0, 1) f (x) ≥ u, i.e. x ∼ US(u)
  • 43. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansSlice sampler Slice sampler algorithm For t = 1, . . . , T when at (x (t) , ω (t) ) simulate 1. ω (t+1) ∼ U[0,f (x (t) )] 2. x (t+1) ∼ US (t+1) , where S (t+1) = {y ; f (y ) ≥ ω (t+1) }.
  • 44. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansSlice sampler Slice sampler algorithm For t = 1, . . . , T 0.010 when at (x (t) , ω (t) ) simulate 0.008 1. ω (t+1) ∼ U[0,f (x (t) )] 0.006 y 2. x (t+1) ∼ US (t+1) , where S (t+1) = {y ; f (y ) ≥ ω (t+1) }. 0.004 0.002 0.000 0.0 0.2 0.4 0.6 0.8 1.0 x
  • 45. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansSlice sampler Slice sampler algorithm For t = 1, . . . , T 0.010 when at (x (t) , ω (t) ) simulate 0.008 1. ω (t+1) ∼ U[0,f (x (t) )] 0.006 y 2. x (t+1) ∼ US (t+1) , where S (t+1) = {y ; f (y ) ≥ ω (t+1) }. 0.004 0.002 0.000 0.0 0.2 0.4 0.6 0.8 1.0 x
  • 46. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansSlice sampler Slice sampler algorithm For t = 1, . . . , T 0.010 when at (x (t) , ω (t) ) simulate 0.008 1. ω (t+1) ∼ U[0,f (x (t) )] 0.006 2. x (t+1) ∼ US (t+1) , where y 0.004 S (t+1) = {y ; f (y ) ≥ ω (t+1) }. 0.002 0.000 0.0 0.2 0.4 0.6 0.8 1.0 x
  • 47. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansSlice sampler Slice sampler algorithm For t = 1, . . . , T 0.010 when at (x (t) , ω (t) ) simulate 0.008 1. ω (t+1) ∼ U[0,f (x (t) )] 0.006 2. x (t+1) ∼ US (t+1) , where y 0.004 S (t+1) = {y ; f (y ) ≥ ω (t+1) }. 0.002 0.000 0.0 0.2 0.4 0.6 0.8 1.0 x
  • 48. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansSlice sampler Slice sampler algorithm For t = 1, . . . , T 0.010 when at (x (t) , ω (t) ) simulate 0.008 1. ω (t+1) ∼ U[0,f (x (t) )] 0.006 2. x (t+1) ∼ US (t+1) , where y 0.004 S (t+1) = {y ; f (y ) ≥ ω (t+1) }. 0.002 0.000 0.0 0.2 0.4 0.6 0.8 1.0 x
  • 49. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansSlice sampler Slice sampler algorithm For t = 1, . . . , T 0.010 when at (x (t) , ω (t) ) simulate 0.008 1. ω (t+1) ∼ U[0,f (x (t) )] 0.006 2. x (t+1) ∼ US (t+1) , where y 0.004 S (t+1) = {y ; f (y ) ≥ ω (t+1) }. 0.002 0.000 0.0 0.2 0.4 0.6 0.8 1.0 x
  • 50. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansSlice sampler Slice sampler algorithm For t = 1, . . . , T 0.010 when at (x (t) , ω (t) ) simulate 0.008 1. ω (t+1) ∼ U[0,f (x (t) )] 0.006 2. x (t+1) ∼ US (t+1) , where y 0.004 S (t+1) = {y ; f (y ) ≥ ω (t+1) }. 0.002 0.000 0.0 0.2 0.4 0.6 0.8 1.0 x
  • 51. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansThe Metropolis–Hastings algorithm Further generalisation of the fundamental idea to situations when the slice sampler cannot be easily implemented
  • 52. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansThe Metropolis–Hastings algorithm Further generalisation of the fundamental idea to situations when the slice sampler cannot be easily implemented Idea Create a sequence (Xn ) such that, for n ‘large enough’, the density of Xn is close to f , only using a ‘local’ knowledge of f ... This is the domain of Markovian simulation methods: there is a Markov dependence between the Xn ’s Markov
  • 53. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansThe Metropolis–Hastings algorithm Further generalisation of the fundamental idea to situations when the slice sampler cannot be easily implemented ‘local’ exploration can produce ‘global’ vision: [ c Civilization 5]
  • 54. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansThe Metropolis–Hastings algorithm (2) If f is the density of interest, we pick a proposal conditional density q(y |xn ) such that it connects with the current value xn it is easy to simulate it is positive everywhere f is positive
  • 55. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansThe Metropolis–Hastings algorithm (2) If f is the density of interest, we pick a proposal conditional density q(y |xn ) such that it connects with the current value xn it is easy to simulate it is positive everywhere f is positive
  • 56. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansRandom walk Metropolis–Hastings Proposal Yt = Xn + εn , where εn ∼ g , independent from Xn , and g symmetrical
  • 57. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansRandom walk Metropolis–Hastings Proposal Yt = Xn + εn , where εn ∼ g , independent from Xn , and g symmetrical Motivation local perturbation of Xn / myopic exploration of its neighbourhood Yn accepted or rejected depending on the relative values of f (Xn ) and f (Yn )
  • 58. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansRandom walk Metropolis–Hastings Proposal Yt = Xn + εn , where εn ∼ g , independent from Xn , and g symmetrical
  • 59. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansRandom walk Metropolis–Hastings Resulting algorithm Random walk Metropolis–Hastings Starting from X (t) = x (t) 1. Generate Yt ∼ g (y − x (t) ) 2. Take f (Yt )  Y with proba. min 1, , (t+1) t X = f (x (t) )  (t) x otherwise
  • 60. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansProperties Always accepts higher point and sometimes lower points (similar to gradient algorithms) Depends on the dispersion de g Average probability of acceptance = min{f (x), f (y )}g (y − x) dxdy close to 1 if g has a small variance [Danger!] far from 1 if g has a large variance [Re-Danger!]
  • 61. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansProperties Always accepts higher point and sometimes lower points (similar to gradient algorithms) Depends on the dispersion de g Average probability of acceptance = min{f (x), f (y )}g (y − x) dxdy close to 1 if g has a small variance [Danger!] far from 1 if g has a large variance [Re-Danger!]
  • 62. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansProperties Always accepts higher point and sometimes lower points (similar to gradient algorithms) Depends on the dispersion de g Average probability of acceptance = min{f (x), f (y )}g (y − x) dxdy close to 1 if g has a small variance [Danger!] far from 1 if g has a large variance [Re-Danger!]
  • 63. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansProperties scale=1
  • 64. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansProperties scale=2
  • 65. Simulation: an ubiquitous tool for statistical computation Producing randomness by deterministic meansProperties scale=3
  • 66. Simulation: an ubiquitous tool for statistical computation Monte Carlo principlesGeneral purpose of Monte Carlo methods Given a probability density f known up to a normalizing constant, ˜ f (x) ∝ f (x), and an integrable function h, compute ˜ h(x)f (x)dx I(h) = h(x)f (x)dx = ˜ f (x)dx when ˜ h(x)f (x)dx is intractable. [Remember π!!]
  • 67. Simulation: an ubiquitous tool for statistical computation Monte Carlo principlesGeneral purpose of Monte Carlo methods Given a probability density f known up to a normalizing constant, ˜ f (x) ∝ f (x), and an integrable function h, compute ˜ h(x)f (x)dx I(h) = h(x)f (x)dx = ˜ f (x)dx when ˜ h(x)f (x)dx is intractable. [Remember π!!]
  • 68. Simulation: an ubiquitous tool for statistical computation Monte Carlo principlesMonte Carlo basics Generate a pseudo-random sample x1 , . . . , xN from f and estimate I(h) by N IN (h) = N −1 ˆ MC h(xi ). i=1 and let N grow to infinity...
  • 69. Simulation: an ubiquitous tool for statistical computation Monte Carlo principlesMonte Carlo basics Generate a pseudo-random sample x1 , . . . , xN from f and estimate I(h) by N IN (h) = N −1 ˆ MC h(xi ). i=1 and let N grow to infinity... A. Doucet, C. Andrieu, X, A. Philippe, J. Rosenthal, E. Moulines
  • 70. Simulation: an ubiquitous tool for statistical computation Monte Carlo principlesMonte Carlo basics Generate a pseudo-random sample x1 , . . . , xN from f and estimate I(h) by N IN (h) = N −1 ˆ MC h(xi ). i=1 and let N grow to infinity...
  • 71. Simulation: an ubiquitous tool for statistical computation Monte Carlo principlesMonte Carlo basics Generate a pseudo-random sample x1 , . . . , xN from f and estimate I(h) by N IN (h) = N −1 ˆ MC h(xi ). i=1 and let N grow to infinity... Caveat Often impossible or inefficient to simulate directly from f
  • 72. Simulation: an ubiquitous tool for statistical computation Monte Carlo principlesImportance Sampling For proposal distribution with density q(x), alternative representations I(h) = h(x){f /q}(x)q(x)dx Principle Generate an iid sample x1 , . . . , xN ∼ q and estimate I(h) by N Iq,N (h) = N −1 ˆ IS h(xi ){f /q}(xi ). i=1
  • 73. Simulation: an ubiquitous tool for statistical computation Monte Carlo principlesImportance Sampling For proposal distribution with density q(x), alternative representations I(h) = h(x){f /q}(x)q(x)dx Principle Generate an iid sample x1 , . . . , xN ∼ q and estimate I(h) by N Iq,N (h) = N −1 ˆ IS h(xi ){f /q}(xi ). i=1
  • 74. Simulation: an ubiquitous tool for statistical computation Simulated annealingOptimisation problems A (genuine) puzzle During a dinner with 20 couples sitting at four tables with ten seats, everyone wants to share a table with everyone. The assembly decides to switch seats after each serving towards this goal. What is the minimal number of servings needed to ensure that every couple shared a table with every other couple at some point? And what is the optimal switching strategy? [http://xianblog.wordpress.com/2012/04/12/not-le-monde-puzzle/] solution to the puzzle
  • 75. Simulation: an ubiquitous tool for statistical computation Simulated annealingStochastic minimisation Example (Egg-box function) Consider the function h(x, y ) = (x sin(20y ) + y sin(20x))2 cosh(sin(10x)x) + (x cos(10y ) − y sin(10x))2 cosh(cos(20y )y ) , to be minimised.
  • 76. Simulation: an ubiquitous tool for statistical computation Simulated annealingStochastic minimisation Example (Egg-box function) Consider the function h(x, y ) = (x sin(20y ) + y sin(20x))2 cosh(sin(10x)x) + (x cos(10y ) − y sin(10x))2 cosh(cos(20y )y ) , to be minimised. (I know that the global minimum is 0 for (x, y ) = (0, 0).)
  • 77. Simulation: an ubiquitous tool for statistical computation Simulated annealingStochastic minimisation Example (Egg-box function) Consider the function h(x, y ) = (x sin(20y ) + y sin(20x))2 cosh(sin(10x)x) + (x cos(10y ) − y sin(10x))2 cosh(cos(20y )y ) , to be minimised. (I know that the global minimum is 0 for (x, y ) = (0, 0).)
  • 78. Simulation: an ubiquitous tool for statistical computation Simulated annealingStochastic minimisation Example (egg-box function (2)) Instead of solving the first order equations ∂h(x, y ) ∂h(x, y ) = 0, =0 ∂x ∂y and of checking that the second order conditions are met, we can generate a random sequence in R2 αj θj+1 = θj + ∆h(θj , βj ζj ) ζj 2βj
  • 79. Simulation: an ubiquitous tool for statistical computation Simulated annealingStochastic minimisation Example (egg-box function (2)) we can generate a random sequence in R2 αj θj+1 = θj + ∆h(θj , βj ζj ) ζj 2βj where the ζj ’s are uniform on the unit circle x 2 + y 2 = 1; ∆h(θ, ζ) = h(θ + ζ) − h(θ − ζ); (αj ) and (βj ) converge to 0
  • 80. Simulation: an ubiquitous tool for statistical computation Simulated annealingCalibration parameters choice 1 2 3 4 αj 1/ log(j + 1) 1/100 log(j + 1) 1/(j + 1) 1/(j + 1) βj 1/ log(j + 1).1 1/ log(j + 1).1 1/(j + 1).5 1/(j + 1).1 α ↓ 0 slowly, j αj = ∞ β ↓ 0 more slowly, 2 j (αj /βj ) < ∞ Scenarios 1-2: not enough energy Scenarios 3-4: good [ c George Casella 1951–2012
  • 81. Simulation: an ubiquitous tool for statistical computation Simulated annealingThe traveling salesman problem A classical allocation problem: Salesman who needs to visit n cities in a row Traveling costs between pairs of cities are known Search of the optimal circuit Procter & Gamble competition, 1962
  • 82. Simulation: an ubiquitous tool for statistical computation Simulated annealingThe traveling salesman problem A classical allocation problem: Salesman who needs to visit n cities in a row Traveling costs between pairs of cities are known Search of the optimal circuit Procter & Gamble competition, 1962
  • 83. Simulation: an ubiquitous tool for statistical computation Simulated annealingThe traveling salesman problem A classical allocation problem: Salesman who needs to visit n cities in a row Traveling costs between pairs of cities are known Search of the optimal circuit Procter & Gamble competition, 1962
  • 84. Simulation: an ubiquitous tool for statistical computation Simulated annealingAn NP-complete problem The traveling salesman problem is an example of mathematical problems that require explosive resolution times
  • 85. Simulation: an ubiquitous tool for statistical computation Simulated annealingAn NP-complete problem The traveling salesman problem is an example of mathematical problems that require explosive resolution times Number of possible circuits n! and exact solutions available in O(2n ) time
  • 86. Simulation: an ubiquitous tool for statistical computation Simulated annealingAn NP-complete problem The traveling salesman problem is an example of mathematical problems that require explosive resolution times Numerous practical consequences (networks, integrated circuit design, genomic sequencing, &tc.)
  • 87. Simulation: an ubiquitous tool for statistical computation Simulated annealingAn NP-complete problem The traveling salesman problem is an example of mathematical problems that require explosive resolution times Number of possible circuits n! and exact solutions available in O(2n ) time Exact solution for 15, 112 German cities found in 2001 in 22.6 CPU years.
  • 88. Simulation: an ubiquitous tool for statistical computation Simulated annealingAn NP-complete problem The traveling salesman problem is an example of mathematical problems that require explosive resolution times Number of possible circuits n! and exact solutions available in O(2n ) time Exact solution for the 24, 978 Sweedish cities found in 2004 in 84.8 CPU years.
  • 89. Simulation: an ubiquitous tool for statistical computation Simulated annealingResolution via simulationThe simulated annealing algorithm: name is borrowed from metallurgy metal manufactured by a slow decrease of temperature (annealing) stronger than when manufactured by fast decrease [ c Joachim Robert, ca. 2006]
  • 90. Simulation: an ubiquitous tool for statistical computation Simulated annealingResolution via simulation Repeat Random modifications of parts of the original circuit with cost C0 Evaluation of the cost C of the new circuit Acceptation of the new circuit with probability C0 − C exp ∧1 T [Metropolis et al., 1953]
  • 91. Simulation: an ubiquitous tool for statistical computation Simulated annealingResolution via simulation Repeat Random modifications of parts of the original circuit with cost C0 Evaluation of the cost C of the new circuit Acceptation of the new circuit with probability C0 − C exp ∧1 T T , temperature, is progressively reduced [Metropolis et al., 1953]
  • 92. Simulation: an ubiquitous tool for statistical computation Simulated annealingA family meeting (1) Recall the table puzzle Definition of a target function Set the story of the 20 couple tables during the 6 courses as a (20, 6) matrix, e.g.,   1 1 3 2 4 2 2 1 3 3 2 4 S = . . . . . .   . . . . . . . . . . . . 3 2 2 2 4 4 and define a penalty function as the number of missed encounters
  • 93. Simulation: an ubiquitous tool for statistical computation Simulated annealingA family meeting (1) Recall the table puzzle Definition of a target function T=sample(rep(1:4,5)) for (i in 2:6) T=cbind(T,sample(rep(1:4,5))) meet=function(T){ M=outer(T[,1],T[,1],"==") for (i in 2:6) M=M+outer(T[,i],T[,i],"==") M } penalty=function(M){ sum(M==0) } penat=penalty(meet(T))
  • 94. Simulation: an ubiquitous tool for statistical computation Simulated annealingA family meeting (2) Random switch of couples Pick two couples [among the 20 couples] at random with probabilities proportional to the number of other couples they have not seen prob=apply(meet(T)==0,1,sum) switch their respective position during one of the 6 courses accept the switch with Metropolis–Hsatings probability log(runif(1))<(penalty(old)-penalty(new))/gamma
  • 95. Simulation: an ubiquitous tool for statistical computation Simulated annealingA family meeting (2) Random switch of couples For instance, propose toreplace     1 1 3 2 4 2 1 1 3 2 2 2 2 1 3 3 2 4 2 1 3 3 4 4  S = . . . . . .  with S =  . . . . . .      . . . . . . . . . . . . . . . . . . . . . . . . 3 2 2 2 4 4 3 2 2 2 4 4
  • 96. Simulation: an ubiquitous tool for statistical computation Simulated annealingA family meeting (2) Random switch of couples for (t in 1:N){ prop=sample(1:20,2,prob=apply(meet(T)==0,1,sum)) cour=sample(1:6,1) Tp=T Tp[prop[1],cour]=T[prop[2],cour] Tp[prop[2],cour]=T[prop[1],cour] penatp=penalty(meet(Tp)) if (log(runif(1))<(penat-penatp)/gamma){ T=Tp penat=penatp} }
  • 97. Simulation: an ubiquitous tool for statistical computation Simulated annealingA family meeting (3) Solution T [1,] 1 4 3 2 2 3 [2,] 1 2 4 3 4 4 [3,] 3 2 1 4 1 3 [4,] 1 2 3 1 1 1 [5,] 4 2 4 2 3 3 [6,] 2 4 1 2 4 1 [7,] 4 3 1 1 2 4 [8,] 1 3 2 4 3 1 [9,] 3 3 3 3 4 3 [10,] 4 4 2 3 1 1 [11,] 1 1 1 3 3 2 [12,] 3 4 4 1 3 2 [13,] 4 1 3 4 4 2 [14,] 2 4 3 4 3 4 [15,] 2 3 4 2 1 2 [16,] 2 2 2 3 2 2 [17,] 2 1 2 1 4 3 [18,] 4 3 1 1 2 4 [19,] 3 1 4 4 2 1 [20,] 3 1 2 2 1 4 [ c http://www.metrolyrics.com]
  • 98. Simulation: an ubiquitous tool for statistical computation Simulated annealingSolving sudokus Solving a Sudoku grid as a minimisation problem: [ c Dan Rice Sudoku blog]
  • 99. Simulation: an ubiquitous tool for statistical computation Simulated annealingSolving sudokus Given a partly filled Sudoku grid (with a single solution), define a random Sudoku grid by filling the empty slots at random s=matrix(0,ncol=9,nrow=9) s[1,c(1,6,7)]=c(8,1,2) s[2,c(2:3)]=c(7,5) s[3,c(5,8,9)]=c(5,6,4) s[4,c(3,9)]=c(7,6) s[5,c(1,4)]=c(9,7) s[6,c(1,2,6,8,9)]=c(5,2,9,4,7) s[7,c(1:3)]=c(2,3,1) s[8,c(3,5,7,9)]=c(6,2,1,9)
  • 100. Simulation: an ubiquitous tool for statistical computation Simulated annealingSolving sudokus Given a partly filled Sudoku grid (with a single solution), define a random Sudoku grid by filling the empty slots at random define a penalty function corresponding to the number of missed constraints #local score scor=function(i,s){ a=((i-1)%%9)+1 b=trunc((i-1)/9) boxa=3*trunc((a-1)/3)+1 boxb=3*trunc(b/3)+1 return(sum(s[i]==s[9*b+(1:9)])+ sum(s[i]==s[a+9*(0:8)])+ sum(s[i]==s[boxa:(boxa+2),boxb:(boxb+2)])-3) }
  • 101. Simulation: an ubiquitous tool for statistical computation Simulated annealingSolving sudokus Given a partly filled Sudoku grid (with a single solution), define a random Sudoku grid by filling the empty slots at random define a penalty function corresponding to the number of missed constraints fill “deterministic” slots make simulated annealing moves # random moves on the sites i=sample((1:81)[as.vector(s)==0],sample(1:sum(s==0),1,pro=1/(1:sum(s==0)))) for (r in 1:length(i)) prop[i[r]]=sample((1:9)[pool[i[r]+81*(0:8)]],1) if (log(runif(1))/lcur<tarcur-target(prop)){ nchange=nchange+(tarcur>target(prop)) cur=prop points(t,tarcur,col="forestgreen",cex=.3,pch=19) tarcur=target(cur) }
  • 102. Simulation: an ubiquitous tool for statistical computation Simulated annealingSolving sudokus many possible variants rather slow may get stuck on a penalty of 2 does not compete with nonrandom solvers