Monte Carlo: Techniques and Theory
Total Page:16
File Type:pdf, Size:1020Kb
Monte Carlo: Techniques and Theory Ronald Kleiss1 IMAPP, Radboud University of Nijmegen version of February 11, 2019 John von Neumann Stanislav Ulam Nick Metropolis the other godfather the other godfather the other godfather `We guarantee that each number is random individually, but we don't guarantee that more than one of them is random' Unnamed programming consultant quoted in [1] [email protected] 1 Contents 1 Introduction: randomness and probability 11 1.1 Protohistory............................ 11 1.2 Random number streamsRandom numbers!stream....... 11 1.2.1 Random numbers: circulus in probando ......... 11 1.2.2 What is a random stream? Relying on probability... 11 1.2.3 What is probability? Relying on a random stream... 12 1.2.4 A difference between physics and mathematics..... 12 1.3 Miscellaneous probability items................. 12 1.3.1 Some notation in these notes............... 12 1.3.2 Moments and characteristic function.......... 13 1.3.3 The Chebyshev-Bienaym´einequality.......... 13 1.3.4 The Central Limit Theorem............... 14 2 Monte Carlo integration 16 2.1 The Monte Carlo idea...................... 16 2.1.1 Point sets and expectation values............ 16 2.1.2 Integration as archetype................. 16 2.1.3 Point sets, ensembles, and the Leap Of Faith..... 17 2.2 Finding estimators........................ 17 2.2.1 Direct sums, unequal-sums, and expectation values.. 17 2.2.2 The Monte Carlo estimators.............. 18 2.2.3 Positivity of E2 and E4 .................. 19 2.3 Estimating in practice...................... 20 2.3.1 Improved estimators................... 20 2.3.2 Numerical stability; the extended CGL algorithm... 20 2.3.3 How to do Monte Carlo integration........... 21 2.3.4 How to report Monte Carlo integration......... 22 2.3.5 How to interpret Monte Carlo integration....... 22 2.4 A test case............................ 23 2.5 Exercises.............................. 26 3 Random number generation 28 3.1 Introduction to random number sources............. 28 3.1.1 Natural vs Pseudo.................... 28 3.2 Pseudo-random number streams................. 29 3.2.1 The structure of pseudo-random number algorithms.. 29 2 3.2.2 The set of all algorithms................. 30 3.2.3 The concept of an arbitrary algorithm......... 30 3.2.4 Lessons from random algorithms............. 31 3.2.5 Shift-register PRNGs................... 32 3.3 Bad and good algorithms..................... 32 3.3.1 Bad: the midsquare algorithm............. 32 3.3.2 Bad: the chaos approach and the logistic map..... 34 3.3.3 Maybe not so bad: linear congruential methods.... 35 3.3.4 Horrible: RANDU, and a possible redemption...... 37 3.3.5 Good: RCARRY and RANLUX ................ 37 3.3.6 Good: the Mersenne Twister............... 39 3.4 Exercises.............................. 41 4 Testing PRNGs 43 4.1 Empirical testing strategies and doubts............. 43 4.1.1 The Leeb Conundrum: too much of a good thing... 43 4.1.2 Any test is a uniformity test............... 44 4.1.3 The χ2 characteristic................... 44 4.2 Theoretical testing strategies................... 46 4.2.1 The number-to-number correlation........... 46 4.2.2 The spectral test..................... 46 4.3 Exercises.............................. 46 5 Quasi-Monte Carlo 48 5.1 Generalities of QMC....................... 48 5.1.1 The New Leap of Faith.................. 48 5.1.2 The mechanism of error improvement......... 49 5.2 Error estimators.......................... 50 5.2.1 The first-order estimate................. 50 5.2.2 The second-order estimate................ 50 5.2.3 Payback time: Lack of Leap of Faith is Punished... 50 6 Nonuniformity of point sets 51 6.1 Measures of nonuniformity: Discrepancy............ 51 6.1.1 The star discrepancy................... 51 6.1.2 Random vs Regular: Translation vs Rotation..... 52 6.1.3 The Roth bound..................... 53 6.1.4 The Koksma-Hlawka inequality............. 53 3 6.1.5 The Wiener measure and the Wo´zniakowski Lemma.. 53 6.2 Measures of nonuniformity: Diaphony.............. 55 6.2.1 Fourier problem classes.................. 55 6.2.2 Fourier diaphony..................... 56 6.2.3 Choosing your strengths: examples of diaphony.... 57 6.3 QFT for diaphony......................... 58 6.3.1 The distribution of diaphony............... 58 6.3.2 Feynman rules for diaphony in the large-N limit.... 59 6.3.3 Collecting bracelets.................... 60 6.3.4 The diaphony distribution for large N ......... 62 6.3.5 The saddle-point approximation............. 63 6.3.6 1=N corrections to the diaphony distribution...... 64 6.3.7 The two-point function................. 65 6.3.8 Testing too much: the Dirac limit............ 67 6.4 Measures of nonuniformity: χ2 ................. 68 6.4.1 The χ2 as a discrepancy................. 68 6.4.2 Large-N results for χ2 .................. 69 6.4.3 Two-point function and 1=N corrections for χ2 ..... 70 7 Superuniform point sets 72 7.1 Fixed point sets vs streams.................... 72 7.1.1 Diaphony minimisation................. 72 7.1.2 Korobov sequences: good lattice points......... 73 7.2 QRNG algorithms......................... 75 7.2.1 Richtmeyer-Kronecker streams.............. 75 7.2.2 Excursion into fractions (cont'd)............. 75 7.2.3 Rational approximations to irrationals......... 76 7.2.4 Almost-equidistancy for Richtmeyer sequences..... 77 7.2.5 van der Corput streams................. 79 7.2.6 Van der Corput sequences in more dimensions..... 81 7.2.7 Niederreiter streams................... 83 8 Variance reduction 84 8.1 Stratified sampling........................ 84 8.1.1 General strategy..................... 84 8.1.2 Uniform stratification................... 85 8.1.3 Stratification as quasification.............. 86 8.1.4 An example: VEGAS .................... 87 4 8.1.5 An example: PARNI .................... 87 8.2 Importance sampling....................... 87 8.2.1 General strategy..................... 87 8.2.2 Multichanneling...................... 87 9 Non-uniform PRNGs 88 9.1 The Art of Transforming, Rejecting, and Being Smart..... 88 9.2 The UA formalism........................ 88 9.2.1 Unitary algorithms as words and as pseudocode.... 88 9.2.2 Inversion of variates in UA................ 90 9.2.3 Rejection of variates in UA............... 91 9.3 Repertoire and the Rule of Nifty................. 93 9.3.1 Building up a repertoire................. 93 9.3.2 The normal distribution: the Box-M¨ulleralgorithm.. 94 9.3.3 The Euler algorithm................... 95 9.3.4 The Kinderman-Monahan algorithm.......... 97 9.4 Random-walk algorithms..................... 98 9.4.1 The Metropolis algorithm................ 99 9.4.2 An elementary case study for Metropolis........ 101 9.4.3 Applications of the Metropolis algorithm........ 102 9.4.4 Gibbs sampling...................... 103 9.4.5 An elementary case study for Gibbs........... 104 10 Phase space algorithms for particle physics 106 10.1 The uniform phase space problem in particle phenomenology. 106 10.2 Two-body phase space...................... 106 10.2.1 The two-body algorithm................. 106 10.2.2 Two-body reduction................... 107 10.3 The relativistic problem..................... 108 10.3.1 Two-body reduction algorithm.............. 108 10.3.2 Massless RAMBO ...................... 109 10.3.3 Inclusion of masses.................... 111 10.4 Nonrelativistic phase space: BOLTZ ............... 113 11 Appendices 116 11.0.1 Falling powers...................... 116 11.0.2 Relations between direct sums and unequal-sums... 117 11.0.3 An exponential sum and the Poisson formula...... 117 5 11.0.4 About the integral (40)................. 118 11.0.5 Selfies........................... 118 11.0.6 Serial correlation in a real-number model........ 119 11.0.7 The two-point function for the Euler diaphony..... 120 11.0.8 Rational denominators for continued fractions..... 120 List of Algorithms 1 Extended CGL algorithm for numerically safe updating of run- ning Monte Carlo estimators................... 22 2 The RCARRY algorithm using a cyclic register........... 38 3 The two major steps of the MT algorithm............. 41 4 The van der Corput transform φb(n).............. 80 5 The Box-M¨ulleralgorithm.................... 95 6 The Euler density with parameters p1; p2; : : : ; pn ........ 96 7 Generating the Cauchy density by ratio of uniforms...... 98 8 Two-bodyp phase space with masses m1;2 and total invariant energy s > m1 + m2 ...................... 107 9 Lorentz boost from P µ, with P 2 = s, at rest to given form, applied on vector pµ. The resultant vector is qµ......... 107 10 The Platzer algorithm for n ≥ 3................. 109 11 The RAMBO algorithm for n momenta with total invariant mass squared s ............................. 111 12 Lorentz boost from P µ, with P 2 = s, to rest from given form, applied on vector pµ. The resultant vector is qµ......... 111 13 Giving masses to massless momenta............... 112 14 The BOLTZ algorithm for total energy U and masses m1;2;:::;n . 114 6 The Buffon fragment from the water's edge, even as much as thou canst gather, [and] bring it to What follows is translated from the the scribe's apprentice. And [the scri- ‘Buffon fragment', clay tablet in Akka- be's apprentice] shall shape thereof [a dian discovered at the site of Jebel-i- tablet of] two cubits; and [the scribe's Qurul, most likely the library of the apprentice] shall draw many [lines on temple precinct of the deity Nisaba, the tablet] so that none approach nor which contained a school of the tupsar separate; and the empty