random numbers and monte carlo methods n.
Skip this Video
Loading SlideShow in 5 Seconds..
Random Numbers and Monte Carlo Methods PowerPoint Presentation
Download Presentation
Random Numbers and Monte Carlo Methods

play fullscreen
1 / 30
Download Presentation

Random Numbers and Monte Carlo Methods - PowerPoint PPT Presentation

Download Presentation

Random Numbers and Monte Carlo Methods

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Random NumbersandMonte Carlo Methods Charles Erwin and Jay Hatcher CS 521 Computational Science

  2. Random Numbers CS 521 Computational Science

  3. Introduction • What are “Random Numbers?” • Where do Random Numbers Come from? • How to make Random numbers? CS 521 Computational Science

  4. Random Numbers • Not just looking for a random number. • Looking for a sequence of numbers that doesn’t repeat. • Do not want a sequence that is deterministic! • Seed: Number that begins the sequence. • Generally the only number that is known initially. CS 521 Computational Science

  5. Why use Random Numbers? • Statistical Sampling • Cryptography/Cryptanalysis • Gaming • Analysis of Algorithms • Simulation Input CS 521 Computational Science

  6. Where to find Random Numbers • Tables of Random Numbers • Classic Example: RAND corp’s A Million Random Digits with 100,000 Normal Deviates • Generated with Electronic simulation of roulette wheel attached to a computer. • Early example of hardware Random Number generator. • Random Number Generator CS 521 Computational Science

  7. Ideas for Random Sequences? • von Neumann’s “Squaring” Method • Take a number, square it, and then use the middle digits as the random number. • What about a seed of 0000? • Linear Congruential Generator • Xn = (aXn-1 + c) mod m • Xo = seed, modulus m, muliplier a, and increment c • Repeats due to the modular arithmetic that forces wrapping of values into the desired range. CS 521 Computational Science

  8. Linear Congruential Generator • Problems (cont) CS 521 Computational Science

  9. Random Numbers from Hardware • Linux Example: /dev/random • Generated by many different factors observed by the operating systems • Avoids tracking things such as network traffic that can be manipulated by outsiders. • Other inputs for random information: • Readings from a Geiger counter • Detected noise from a radio receiver • Thermal or quantum-mechanical noise, amplified to provide a random voltage source. CS 521 Computational Science

  10. Random Numbers from Hardware(cont) • Internal CPU Random Number Generator • Modern Intel chips feature an internal RNG • Samples thermal noise by amplifying the voltage measured across undriven resistors. • Analysis determines it cryptographically sound. • Unconventional Source: Lava Lamps • Random bits are extracted from images of the erupting blobs inside six Lava Lite lamps. No longer available. • LavaRnd provided random data using similar methods. • http://www.lavarnd.org/what/index.html CS 521 Computational Science

  11. Random Numbers from Hardware(cont) • Commercial Random Number Generators • Operate from USB or Serial connections • Standard mode is to deliver one byte of data at a time. • Current models pass DIEHARD battery of tests • Very fast generation. • Prices range anywhere from ~$100 to more than $1,000 per unit. CS 521 Computational Science

  12. Software Random Generators • Random Number Algorithm an oxymoron. • von Neumann: “Anyone who uses software to produce random numbers is in a state of sin” • Deterministic Random number generators are called “Pseudorandom Number generators” • Clever algorithms can create sequences that are relatively random. CS 521 Computational Science

  13. Modern Generator Example 1 • Mersenne Twister by Makoto Matsumoto and Takuji Nishimura • Period size: 2^19937-1 • Freely Available in C source code • Fast (used to be much faster than the C rand() functionality but rand() has since been improved) • Not cryptographically secure CS 521 Computational Science

  14. Modern Generator Example 2 • Blum Blum Shub (BBS) by Lenore Blum, Manuel Blum and Michael Shub • Xn+1 = (Xn)2 mod M • M=pq is the product of two large primes p and q • Proven to be cryptographically secure • Very slow CS 521 Computational Science

  15. Summary of Algorithms • Different generators are more appropriate for specific circumstances. • For Cryptanalysis or Cryptography, finding an algorithm which is cryptographically secure is essential. • For Simulations such as Monte-Carlo, a fast algorithm is preferred. CS 521 Computational Science

  16. Summary (cont.) • If your application is security based, your choices are limited to cryptographically secure random number generators. • Otherwise, use the normal algorithm analysis questions of correctness and complexity. CS 521 Computational Science

  17. Quick list of References • Linear Congruential Generator: http://eternallyconfuzzled.com/tuts/random.html http://www.taygeta.com/rwalks/node1.html • Randomness as a Resource:http://www.americanscientist.org/template/AssetDetail/assetid/20829/page/3 • Hardware Random Number Generators: http://www.robertnz.net/hwrng.htm • Mersenne Twister: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html • Blum Blum Shub: http://en.wikipedia.org/wiki/Blum-Blum-Shub_pseudorandom_number_generator • DIEHARD Random Tests: http://www.cs.hku.hk/~diehard/cdrom/ • Security Requirements for Random Numbers: http://www.ietf.org/rfc/rfc4086.txt • Intel’s internal RNG: http://www.cryptography.com/resources/whitepapers/IntelRNG.pdf CS 521 Computational Science

  18. Monte Carlo Methods CS 521 Computational Science

  19. Introduction • “Monte Carlo” was coined by Metropolis during the Manhattan Project of WWII • Named after a resort town in Monaco famous for its casinos • Monte Carlo methods use statistical simulation to approximate a solution to a problem CS 521 Computational Science

  20. Integration Methods • Direct Sampling • Random Walk and Markov Chains CS 521 Computational Science

  21. Integration Methods (cont) • Direct Sampling • Importance Sampling • Stratified Sampling • Adaptive Monte Carlo • VEGAS algorithm • Recursive Stratified Sampling CS 521 Computational Science

  22. Integration Methods (cont) • Markov Chain Monte Carlo (MCMC) • Random Walks • Metropolis-Hastings Algorithm • Gibbs Sampling CS 521 Computational Science

  23. Optimization Methods • Genetic Algorithms • Simulated Annealing • Parallel Tempering CS 521 Computational Science

  24. Optimization Methods (cont) • Genetic Algorithms • Explore solution space using subsequent generations • Generations that are better are combined and/or mutated to try to produce an even better solution CS 521 Computational Science

  25. Optimization Methods (cont) • Simulated Annealing • Inspired by annealing in metallurgy • Nearby solutions are compared to the global temperature T • T is gradually decreased CS 521 Computational Science

  26. Optimization Methods (cont) • Parallel Tempering • Run two or more simulations concurrently at different temperatures • Pay attention to overlap between the two systems and use the overlap to pick more likely solutions CS 521 Computational Science

  27. Other Methods • Direct Simulation • Stochastic simulation of rarefied gas flows • DSMC Demo • Dynamic Monte Carlo • models the dynamic behaviors of molecules • Quantum Monte Carlo • Applies MC to the Schrödinger wave equation in quantum mechanics CS 521 Computational Science

  28. Example: Approximating π • π is 4 times the number of dartsin the shaded part of the quadrant divided by the total darts in the quadrant • Buffon’s Needle CS 521 Computational Science

  29. Applications Radiation transport Operations research Nuclear criticality Design of nuclear reactors Design of nuclear weapons Statistical physics Phase transitions Wetting and growth of thin films Reinforcement Learning Genetic Programming Atomic wave functions and Intranuclear cascade reactions eigenvalues Thermodynamic properties Long chain coiling polymers Reaction kinetics Partial differential equations Large sets of linear equations Numerical integration Uncertainty analysis Development of statistical tests Cell population studies Combinatorial problem Search and optimization Signal detection WarGames CS 521 Computational Science

  30. References and Additional Info • Introduction to Monte Carlo Methods • http://csep1.phy.ornl.gov/mc/mc.html • Adaptive and Recursive Monte Carlo Methods • http://www.library.cornell.edu/nr/bookcpdf/c7-8.pdf • The WWW Virtual Library: Monte Carlo Methods • http://random.mat.sbg.ac.at/links/monte.html • The Basics of Monte Carlo Simulations • http://www.chem.unl.edu/zeng/joy/mclab/mcintro.html • Advanced Monte Carlo Methods • http://www.cs.pitt.edu/~milos/courses/cs3750/lectures/class10.pdf • Monte Carlo Methods (Reinforcement Learning) • http://www.cs.ualberta.ca/~sutton/book/5/node1.html • Buffon’s Needle (applet) • http://www.angelfire.com/wa/hurben/buff.html • Direct Simulation MC • http://www.simba.us/misc/dsmc/dsmca.html CS 521 Computational Science