Presentation is loading. Please wait.

Presentation is loading. Please wait.

Random Number Generators CISC/QCSE 810. What is random? Flip 10 coins: how many do you expect will be heads? Measure 100 people: how are their heights.

Similar presentations


Presentation on theme: "Random Number Generators CISC/QCSE 810. What is random? Flip 10 coins: how many do you expect will be heads? Measure 100 people: how are their heights."— Presentation transcript:

1 Random Number Generators CISC/QCSE 810

2 What is random? Flip 10 coins: how many do you expect will be heads? Measure 100 people: how are their heights distributed? How would you recognize an outlying data point?

3 True randomness Surprisingly hard to define Best identified by its absence simulate a sequence of events many times (millions) and see if data distribution matches theoretical one bad sequences hard to identify with few (thousands) of samples

4 Computer Example Sample 100 normally distributed random variables based on population height characteristics

5 How did it do that?? The computer includes a pseudo- random number generator function

6 Randomness and Number Theory Surprisingly, most pseudo-random number generators are developed through applications of number theory number theory usually considered the most 'pure' of mathematics also considered the least random! Connection is that integers are well-understood, not rounded off, can generate long, non-repetitive cycles

7 Congruential Generator Function is linear (so random?) 'randomness' comes from modulus, or 'clock arithmetic' improves (generally) with larger m, and prime m can still be ruined by bad a, b values

8 Simple Examples a = 10, b = 2, m = 13 a = 769, b = 3, m = 1001 a = 16807, b = 0, m = 2147483647

9 Lagged Fibonacci Examples: r = 17, s = 5, N = 2^32 r= 68, s = 33, N = 2^32 Can initialize first part of series with any values Throw away first collection (see graph)

10 Common features All generate a sequence of pseudo-random numbers must set a 'seed' for the sequence All sequences generate uniformly distributed numbers on [0, N) some real-valued algorithms exist, but generally integer are preferred because of lack of round-off error All will eventually reach back to start of a cycle 2^32 = 4 x 10^9 best case for those shown Converting to [0, 1) range: divide by N

11 Applications Multivariate numerical integration large number of dimensions Simulating inter-related probabilities Gibbs sampling Direct simulation models with error, randomness molecular simulations Graph simulations binary values represent connections

12 Integration Simpson's rule, etc. are sufficiently efficient on one, two, three variable problems Problems in 6,7, or higher dimensions, much less so! grid size is to (num intervals)^D Alternative approach: generate random samples from space, take average of function at those points

13 3D Example: sphere Estimate the volume of the 3D and 10D (hyper)-sphere Take uniform samples on hypercube [-1 1]^3 or [-1 1]^10 Percentage that fall inside sphere (easy to check) represent percent volume of cube inside (hyper)-sphere

14 Convergence

15 Quasi-random numbers Pseudo random are best for real randomness last value doesn’t predict value of next For integration in particular, want guarantees of fast coverage of hyper-volumes last value should depend on previous ones Sampling almost on a grid, but able to stop at any point in the sampling Search for Sobol sequences, or low discrepancy sequences (LDS)

16 2D Example – Halton Sequence

17 Volume of 6D Sphere

18 Testing Random Numbers Tests for randomness are usually statistical, and require long sequences (millions of values) Some subtle correlations can occur that can affect simulations some more than others; depends on interpretation of the values (binary, floating point, dimensionality, etc.) See Marsaglia for references and test suites (Diehard suite)

19 "Physical" randomness Machines exist measure time between radioactive decay events Surprisingly, values from these are often 'less' random than computer- generated ones! Don't take randomness on faith (or advertising)

20 Summary Randomness is difficult to define Generating sequences of random numbers is not a trivial exercise use references! If possible, develop or borrow tests before you start using a generator


Download ppt "Random Number Generators CISC/QCSE 810. What is random? Flip 10 coins: how many do you expect will be heads? Measure 100 people: how are their heights."

Similar presentations


Ads by Google