Lehmer Random Number Generators: Introduction

Size: px
Start display at page:

Download "Lehmer Random Number Generators: Introduction"

Transcription

1 Lehmer Random Number Generators: Introduction Revised version of the slides based on the book Discrete-Event Simulation: a first course LL Leemis & SK Park Section(s) 21, 22 c 2006 Pearson Ed, Inc Discrete-Event Simulation Lehmer Random Number Generators: Introduction 1/48

2 Random Number Generators Historically there are three types of generators table look-up generators hardware generators algorithmic (software) generators Algorithmic generators are widely accepted because they meet all of the following criteria: randomness - output passes all reasonable statistical tests of randomness controllability - able to reproduce output, if desired portability - able to produce the same output on a wide variety of computer systems efficiency - fast, minimal computer resource requirements documentation - theoretically analyzed and extensively tested Discrete-Event Simulation Lehmer Random Number Generators: Introduction 2/48

3 Algorithmic Generators An ideal random number generator produces output such that each value in the interval 00 < u < 10 is equally likely to occur A good random number generator produces output that is (almost) statistically indistinguishable from an ideal generator We will discuss a good random number generator satisfying all our criteria Discrete-Event Simulation Lehmer Random Number Generators: Introduction 3/48

4 Conceptual Model Conceptual Model: Choose a large positive integer m This defines the set X m = {1, 2,, m 1} Fill a (conceptual) urn with the elements of X m Each time a random number u is needed, draw an integer x at random from the urn and let u = x/m Each draw simulates a sample of an independent identically distributed sequence of Uniform(0, 1) The possible values are 1/m, 2/m, (m 1)/m It is important that m be large so that the possible values are densely distributed between 00 and 10 Discrete-Event Simulation Lehmer Random Number Generators: Introduction 4/48

5 Conceptual Model 00 and 10 are impossible This is important for some random variates We would like to draw from the urn with replacement For practical reasons, we will draw without replacement If m is large and the number of draws is small relative to m, then the distinction becomes irrelevant Discrete-Event Simulation Lehmer Random Number Generators: Introduction 5/48

6 Lehmer s Algorithm Lehmer s algorithm (also called Linear Congruential Generator) for random number generation is defined in terms of two fixed parameters: modulus m, a fixed large prime integer multiplier a, a fixed integer in X m The integer sequence x 0, x 1, is defined by the iterative equation x i+1 = g(x i ) with g(x) = ax mod m x 0 X m is called the initial seed Discrete-Event Simulation Lehmer Random Number Generators: Introduction 6/48

7 Lehmer Generators Because of the mod operator, 0 g(x) < m However, 0 must not occur since g(0) = 0 Since m is prime, g(x) 0 if x X m If x 0 X m, then x i X m for all i 0 If the multiplier and prime modulus are chosen properly, a Lehmer generator is statistically indistinguishable from drawing from X m with replacement Note, there is nothing random about a Lehmer generator For this reason, it is called a pseudo-random generator Discrete-Event Simulation Lehmer Random Number Generators: Introduction 7/48

8 Intuitive Explanation ax/m m g(x) ax 0 x a m 2m 3m 4m 5m ax When ax is divided by m, the remainder is likely to be any value between 0 and m 1 Discrete-Event Simulation Lehmer Random Number Generators: Introduction 8/48

9 Parameter Considerations The choice of m is dictated, in part, by system considerations On a system with 32-bit 2 s complement integer arithmetic, is a natural choice With 16-bit or 64-bit integer representation, the choice is not obvious In general, we want to choose m to be the largest representable prime integer Given m, the choice of a must be made with great care Discrete-Event Simulation Lehmer Random Number Generators: Introduction 9/48

10 Simple example (Lehmer Generator) Effects of choosing different values for the multiplier Switch to Random WS 1 Click Here Discrete-Event Simulation Lehmer Random Number Generators: Introduction 10/48

11 Example - Period If m = 13 and a = 6 with x 0 = 1 then the sequence is 1, 6, 10, 8, 9, 2, 12, 7, 3, 5, 4, 11, 1, The ellipses indicate the sequence is periodic If m = 13 and a = 7 with x 0 = 1 then the sequence is 1, 7, 10, 5, 9, 11, 12, 6, 3, 8, 4, 2, 1 Because of the 12, 6, 3 and 8, 4, 2, 1 patterns, this sequence appears less random If m = 13 and a = 5 then 1, 5, 12, 8, 1, or 2, 10, 11, 3, 2, or 4, 7, 9, 6, 4, This less-than-full-period behavior is obviously undesirable Discrete-Event Simulation Lehmer Random Number Generators: Introduction 11/48

12 Central Issues Given a modulus m a Full Period sequence contains all the numbers in the set (0, m) before repeating itself For a chosen (a, m) pair, does the function g() generate a full-period sequence? If a full period sequence is generated, how random does the sequence appear to be? Can ax mod m be evaluated efficiently and correctly? Integer overflow can occur when computing ax Discrete-Event Simulation Lehmer Random Number Generators: Introduction 12/48

13 Full Period Considerations Theorem If x 0 X m and the sequence x 0, x 1, x 2 is produced by a Lehmer generator with multiplier a and (prime) modulus m then there is a positive integer p with p m 1 such that x 0, x 1, x 2 x p 1 are all different and x i+p = x i i = 0, 1, 2, That is, the sequence is periodic with fundamental period p In addition (m 1) mod p = 0 Discrete-Event Simulation Lehmer Random Number Generators: Introduction 13/48

14 Full Period Multipliers If we pick any initial seed x 0 X m and generate the sequence x 0, x 1, x 2, then x 0 will occur again Further x 0 will reappear at index p that is either m 1 or a divisor of m 1 The pattern will repeat forever We are interested in choosing full-period multipliers where p = m 1 Discrete-Event Simulation Lehmer Random Number Generators: Introduction 14/48

15 Example - Many full period sequences Full-period multipliers generate a virtual circular list with m 1 distinct elements (a, m) = (6, 13) (a, m) = (7, 13) Discrete-Event Simulation Lehmer Random Number Generators: Introduction 15/48

16 Finding Full Period Multipliers Algorithm p = 1; x = a; while (x!= 1) { p++; x = (a x)% m; /* beware of a x overflow */ } if(p == m 1) /* a is a full-period multiplier */ else /* a is not a full-period multiplier */ This algorithm corresponds to a naif implementation of Lehmer methods with x 0 = 1 It simply counts how many numbers are generated before getting back 1 It does not exploit any property of the method It is a slow-but-sure way to test for a full-period multiplier Discrete-Event Simulation Lehmer Random Number Generators: Introduction 16/48

17 Frequency of Full-Period Multipliers Given a prime modulus m, how many corresponding full-period multipliers are there? Theorem If m is prime and p 1, p 2,, p r are the (unique) prime factors of m 1 then the number of full-period multipliers in X m is (p 1 1)(p 2 1) (p r 1) p 1 p 2 p r (m 1) Discrete-Event Simulation Lehmer Random Number Generators: Introduction 17/48

18 Simple example (full period multipliers) Compare sequences generated using different multipliers Switch to Random WS 2 Click Here Discrete-Event Simulation Lehmer Random Number Generators: Introduction 18/48

19 Example If m = = 2, 147, 483, 647 then since the prime decomposition of m 1 is m 1 = = the number of full period multipliers is ( ) ( ) = 534, 600, Therefore, approximately 25% of the multipliers are full-period Discrete-Event Simulation Lehmer Random Number Generators: Introduction 19/48

20 Finding All Full-Period Multipliers Once one full-period multiplier has been found, then all others can be found in O(m) time Algorithm i = 1; x = a; while (x!= 1) { if(gcd(i, m 1) == 1) /* if i and (m 1) are relative prime a i mod m is a full-period multiplier*/ i++ x = (a * x) % m; /* beware a x overflow */ } Recall that two numbers are relative prime if they do not share any common divisor (except 1) Discrete-Event Simulation Lehmer Random Number Generators: Introduction 20/48

21 Finding All Full-Period Multipliers Theorem If a is any full-period multiplier relative to the prime modulus m then each of the integers a i mod m X m i = 1, 2, 3,, m 1 is also a full-period multiplier relative to m if and only if i and m 1 are relatively prime Discrete-Event Simulation Lehmer Random Number Generators: Introduction 21/48

22 Example If m = 13 then we know from previous examples there are 4 full period multipliers and one of them is a = 6 Then, since 1, 5, 7, and 11 are relatively prime to mod 13 = mod 13 = mod 13 = mod 13 = 11 Equivalently, if we knew a = 2 is a full-period multiplier 2 1 mod 13 = mod 13 = mod 13 = mod 13 = 7 Discrete-Event Simulation Lehmer Random Number Generators: Introduction 22/48

23 Simple example (finding full period multipliers) Simple Lehmer generator with a = 5 and m = 23 Switch to Random WS 3 Click Here Discrete-Event Simulation Lehmer Random Number Generators: Introduction 23/48

24 Example If m = we already observed that there are 534,600,000 integers relatively prime to m 1 The first few are i = 1, 5, 13, 17, 19 a = 7 is a full-period multiplier relative to m and therefore 7 1 mod = mod = mod = mod = mod = are full-period multipliers relative to m Discrete-Event Simulation Lehmer Random Number Generators: Introduction 24/48

25 Modulus Compatibility Definition The multiplier a is modulus-compatible with (prime modulus) m if and only if the remainder r = m mod a is less than the quotient q = m/a For implementation, efficiency and portability reasons, it is useful to choose the multiplier a to be both Full period Modulus-compatible Discrete-Event Simulation Lehmer Random Number Generators: Introduction 25/48

26 Other Multipliers and Considerations for m = there are multipliers a that are full period of these are modulus compatible (smaller than the m) In the next lecture, we will discuss statistical tests for these numbers, but a lot of research has already been done Nonrepresentative Subsequences: What if only 20 random numbers were needed and you chose seed x 0 = ? Resulting 20 random numbers: Discrete-Event Simulation Lehmer Random Number Generators: Introduction 26/48

27 Randomness Randomness properties are not less important that full period capabilities Choose the FPMC (Full Period Modulus Compatible) multiplier that gives most random sequence No universal definition of randomness exists In 2-space, (x 0, x 1 ), (x 1, x 2 ), (x 2, x 3 ), form a lattice structure For any integer k 2, the points (x 0, x 1,, x k 1 ), (x 1, x 2,, x k ), (x 2, x 3,, x k+1 ), form a lattice structure in k-space Numerically analyze uniformity of the lattice Discrete-Event Simulation Lehmer Random Number Generators: Introduction 27/48

28 Random Numbers Falling In The Planes (a, m) = (23, 401) (a, m) = (66, 401) Discrete-Event Simulation Lehmer Random Number Generators: Introduction 28/48

29 Scatter Plot Of 400 Pairs Initial seed x 0 = Initial seed x 0 = Discrete-Event Simulation Lehmer Random Number Generators: Introduction 29/48

30 Observations on Randomness In previous figure, no lattice structure is evident Appearance of randomness is an illusion If all m 1 = points were generated, lattice would be evident Herein lies distinction between ideal and good RNGs Discrete-Event Simulation Lehmer Random Number Generators: Introduction 30/48

31 Example Plotting all pairs (x i, x i+1 ) for m = would give a black square Any tiny square should appear (approximately) the same But if we were Zooming in we would see results similar to those depicted in the following figure obtained for multipliers a = and a = on the next slide Discrete-Event Simulation Lehmer Random Number Generators: Introduction 31/48

32 Scatter Plots for m = Multiplier a = Multiplier a = Further justification for using a = over a = Discrete-Event Simulation Lehmer Random Number Generators: Introduction 32/48

33 Tests for Randomness Pseudo-random number generators are intrinsically non-random, however we accept the fact that they apppear random, if the generation method (parameters of the Lehmer Generator) are not explicitly known Statistical tests can be performed on sequences of generated random numbers to quantify their randomness The more statistical tests are passed by a generator the better its quality is assumed The chi-square test is commonly used to quantify the randomness of long, but finite (and in any case much shorter than the period of the generator) sequences of (generated) random numbers Discrete-Event Simulation Lehmer Random Number Generators: Introduction 33/48

34 Simple example (preliminary observations on randomness) Filtering the sequence of numbers produced by Lehmer generator to appear more random Switch to Random WS 4 Click Here Discrete-Event Simulation Lehmer Random Number Generators: Introduction 34/48

35 Chi-square statistic Let x be a random variable assuming values in interval X = (0, m) Suppose that the possible values of x be partitioned into k adjacent intervals (a 0, a 1 ], (a 1, a 2 ],, (a k 1, a k ) to form a new (discrete) random variable y that assumes values in the set Y k = {0, 1,, k 1} Based on a large number n of independent observations of y, for each (possible) value y j, let N j be the number of times y j occurs η j = np j be the expected number of times y j occurs, where p j is the probability of an outcome (observation) in (a j 1, a j ] 1 Then the resulting non-negative quantity V = k j=1 (N j η j ) 2 η j is known as a chi-square statistic 1 The fact that (a k 1, a k ) is open is not relevant for practical purposes Discrete-Event Simulation Lehmer Random Number Generators: Introduction 35/48

36 Chi-square test If the sample of the random variable x, represented by the sequence X = {x 1, x 2,, x n } is truly an iid random variate sample from the desired distribution and if n/k is sufficiently large (> 10) then the statistic V is approximately a X 2 random variate with n 1 degrees of freedom In these conditions, let v1 = χ2 (k 1, α/2) be the percentile such that Pr{X 2 (n 1) χ 2 (k 1, α/2)} = α/2 v2 = χ2 (k 1, 1 α/2) be the percentile such that Pr{X 2 (k 1) χ 2 (k 1, 1 α)} = 1 α/2 then Pr{v1 < V v 2 } = 1 α, ie, the Chi-square statistic V belongs to the interval (v1, v 2 ) with confidence level (1 α) Typically the confidence level α is chosen to be equal to 005 Discrete-Event Simulation Lehmer Random Number Generators: Introduction 36/48

37 Chi-square percentile table df χ χ 2 01 χ χ 2 05 χ 2 10 χ 2 90 χ 2 95 χ χ 2 99 χ Discrete-Event Simulation Lehmer Random Number Generators: Introduction 37/48

38 Chi-square test interpretation With the help of the Chi-square percentile table it is possible to accept the test hypothesis using the following criteria: A value of V is considered acceptable with 95% confidence if it falls between the columns 2 χ 025 and χ 975 of the table A value of V is refused if it falls before column χ 005 or after column χ 995 A value of V is considered dubious otherwise More detailed distinctions can be made according to the following criteria A value of V is considered dubiousif it falls between the columns χ 005 and χ 001 or between the columns χ 99 and χ 995 A value of V is considered quasi-dubious if it falls between the columns χ 01 and χ 025 or between the columns χ 975 and χ 99 A test of this type is called Two-Tailed test 2 columns report values for different degrees of freedom Discrete-Event Simulation Lehmer Random Number Generators: Introduction 38/48

39 Chi Square Density function 2 025(9)= (9)= (9)= (9)=1902 Discrete-Event Simulation Lehmer Random Number Generators: Introduction 39/48

40 Empirical tests of randomness based on the Chi-square test Different tests of randomness can be performed on the sequence produced by a random number generator using the Chi-square test The most common ones are: Uniformity Test - Is the histogram flat Bivariate Uniformity Test - Serial test Gap Test of independence Many other tests have been proposed to check the properties of the Random Number Generator using other points of view (see Knuth DE, The Art of Computer Programming, Vol2: Seminumerical Algorithms ) Discrete-Event Simulation Lehmer Random Number Generators: Introduction 40/48

41 Uniformity Test Divide the interval (0, 1) into k subintervals of equal length Generate U 1, U 2,,U n It is recommended to choose k 100 and n/k 5 Let N j be the number of the n U i s in the j-th subinterval Then V = k n k j=1 ( N j n ) 2 k is approximately a X 2 random variate with k 1 degrees of freedom Discrete-Event Simulation Lehmer Random Number Generators: Introduction 41/48

42 Simple example (uniformity test) Application of the Chi-square test to check uniformity Sensitivity of the test with respect to length of sequence Switch to Random WS 5-6 Click Here Discrete-Event Simulation Lehmer Random Number Generators: Introduction 42/48

43 Serial Test 2-dimensional version of the Uniformity test to assess the independence between successive observations Divide the interval (0, 1) into k subintervals of equal length Generate U 1, U 2,,U 2n If the U i s are really iid, then the non-overlapping pairs (U 1, U 2 ), (U 3, U 4 ),, (U 2n 1, U 2n ) are iid random vectors uniformly distributed in the square (0, 1) 2 Count the number of outcomes that fall in each sub-square (ie, let N ij be the number of pairs in the (i, j)-th sub-square) Then V = k2 n k i=1 j=1 k (N ij n ) 2 k 2 is approximately a X 2 random variate with k 2 1 degrees of freedom Obviously this test can be generalized to higher dimensions Discrete-Event Simulation Lehmer Random Number Generators: Introduction 43/48

44 Gap Test The Gap test checks the randomness of the generator with a non-local view Define two values α and β (α < β) within the interval (0, 1) Let q, equal to (β α), be the probability that a random number U is in the interval (α, β) Generate U 1, U 2,,U 2n Transform the {U i } sequence into the {I i } sequence using the following definition I i = { 1 if Ui (α, β) 0 Otherwise Identify consecutive subsequences I j, I j+1,, I j+r, I j+(r+1) such that I j and I j+(r+1) = 1, but the other elements in the subsequence are = 0 This is a gap of length r Discrete-Event Simulation Lehmer Random Number Generators: Introduction 44/48

45 Gap Test (cont) Perform a chi-square test using the different (possible) lengths of the gaps as categories and the probabilities as follows p r = q(1 q) r, r = 0, 1, 2, The size of a gap may grow up to, thus we consolidate the gaps, choosing and arbitrary upper value k and counting together all the gaps of length (k 1) or greater The probability of this consolidated event is Pr{r k 1} = (1 q) k 1 Since the gaps have a geometric distribution with parameter (1 δ), the expected gap length is E[r] = 1 q q Small values of q = (α β) yield gaps of large size Discrete-Event Simulation Lehmer Random Number Generators: Introduction 45/48

46 Gap Test (cont) The choice of k and of q have a large impact on the length of the sequence of random numbers that we use for the test the larger is the value of k the less local is the randomness test large values of k make the probability of having gaps of length larger of k 2 small small values of q makes the test more focused the length of the sequence of random numbers n may be evaluated in the following manner m n E[r] Pr{r k 1} = m q(1 q) k 2 where m is the minimum number of expected gaps of length (k 1) Usually we choose m 10 Discrete-Event Simulation Lehmer Random Number Generators: Introduction 46/48

47 Final Considerations How do we use these tests to check the quality of a random Number Generator? If the generator to be tested is truly awful, then it may be sufficient to use some of these tests to see if failures a consistently produced If the generator is not so bad (but also not so good) then there will be some test that will reveal its deficiency, but unfortunately there are no simple rules for finding the test that identifies this situation If the generator is good, then it should fail any of these tests approximately only αx100% of the time where α is the confidence level of the test (ie, we repeat the tests many times and we should observe only a very limited number of failures) Discrete-Event Simulation Lehmer Random Number Generators: Introduction 47/48

48 Good Random Number Generators The quality of a random Number Generator is vital for providing reliable simulation results The Mathematic Department of the Hiroshima University is known to develop and to maintain random number generators of high quality The Marsenne Twister Generator is a very fast random number generator of period p = (> ) m-mat/mt/emthtml It shows very good statistical randomness It is the default Pseudo Random Number Generator of many contemporary languages Discrete-Event Simulation Lehmer Random Number Generators: Introduction 48/48

Section 2.1: Lehmer Random Number Generators: Introduction

Section 2.1: Lehmer Random Number Generators: Introduction Section 21: Lehmer Random Number Generators: Introduction Discrete-Event Simulation: A First Course c 2006 Pearson Ed, Inc 0-13-142917-5 Discrete-Event Simulation: A First Course Section 21: Lehmer Random

More information

CPSC 531: Random Numbers. Jonathan Hudson Department of Computer Science University of Calgary

CPSC 531: Random Numbers. Jonathan Hudson Department of Computer Science University of Calgary CPSC 531: Random Numbers Jonathan Hudson Department of Computer Science University of Calgary http://www.ucalgary.ca/~hudsonj/531f17 Introduction In simulations, we generate random values for variables

More information

Uniform random numbers generators

Uniform random numbers generators Uniform random numbers generators Lecturer: Dmitri A. Moltchanov E-mail: moltchan@cs.tut.fi http://www.cs.tut.fi/kurssit/tlt-2707/ OUTLINE: The need for random numbers; Basic steps in generation; Uniformly

More information

B. Maddah ENMG 622 Simulation 11/11/08

B. Maddah ENMG 622 Simulation 11/11/08 B. Maddah ENMG 622 Simulation 11/11/08 Random-Number Generators (Chapter 7, Law) Overview All stochastic simulations need to generate IID uniformly distributed on (0,1), U(0,1), random numbers. 1 f X (

More information

Topics in Computer Mathematics

Topics in Computer Mathematics Random Number Generation (Uniform random numbers) Introduction We frequently need some way to generate numbers that are random (by some criteria), especially in computer science. Simulations of natural

More information

Random Number Generation. CS1538: Introduction to simulations

Random Number Generation. CS1538: Introduction to simulations Random Number Generation CS1538: Introduction to simulations Random Numbers Stochastic simulations require random data True random data cannot come from an algorithm We must obtain it from some process

More information

Slides 3: Random Numbers

Slides 3: Random Numbers Slides 3: Random Numbers We previously considered a few examples of simulating real processes. In order to mimic real randomness of events such as arrival times we considered the use of random numbers

More information

Uniform Random Number Generators

Uniform Random Number Generators JHU 553.633/433: Monte Carlo Methods J. C. Spall 25 September 2017 CHAPTER 2 RANDOM NUMBER GENERATION Motivation and criteria for generators Linear generators (e.g., linear congruential generators) Multiple

More information

Algorithms and Networking for Computer Games

Algorithms and Networking for Computer Games Algorithms and Networking for Computer Games Chapter 2: Random Numbers http://www.wiley.com/go/smed What are random numbers good for (according to D.E. Knuth) simulation sampling numerical analysis computer

More information

Generating Uniform Random Numbers

Generating Uniform Random Numbers 1 / 43 Generating Uniform Random Numbers Christos Alexopoulos and Dave Goldsman Georgia Institute of Technology, Atlanta, GA, USA March 1, 2016 2 / 43 Outline 1 Introduction 2 Some Generators We Won t

More information

A Repetition Test for Pseudo-Random Number Generators

A Repetition Test for Pseudo-Random Number Generators Monte Carlo Methods and Appl., Vol. 12, No. 5-6, pp. 385 393 (2006) c VSP 2006 A Repetition Test for Pseudo-Random Number Generators Manuel Gil, Gaston H. Gonnet, Wesley P. Petersen SAM, Mathematik, ETHZ,

More information

2 P. L'Ecuyer and R. Simard otherwise perform well in the spectral test, fail this independence test in a decisive way. LCGs with multipliers that hav

2 P. L'Ecuyer and R. Simard otherwise perform well in the spectral test, fail this independence test in a decisive way. LCGs with multipliers that hav Beware of Linear Congruential Generators with Multipliers of the form a = 2 q 2 r Pierre L'Ecuyer and Richard Simard Linear congruential random number generators with Mersenne prime modulus and multipliers

More information

Tae-Soo Kim and Young-Kyun Yang

Tae-Soo Kim and Young-Kyun Yang Kangweon-Kyungki Math. Jour. 14 (2006), No. 1, pp. 85 93 ON THE INITIAL SEED OF THE RANDOM NUMBER GENERATORS Tae-Soo Kim and Young-Kyun Yang Abstract. A good arithmetic random number generator should possess

More information

Systems Simulation Chapter 7: Random-Number Generation

Systems Simulation Chapter 7: Random-Number Generation Systems Simulation Chapter 7: Random-Number Generation Fatih Cavdur fatihcavdur@uludag.edu.tr April 22, 2014 Introduction Introduction Random Numbers (RNs) are a necessary basic ingredient in the simulation

More information

Review of Statistical Terminology

Review of Statistical Terminology Review of Statistical Terminology An experiment is a process whose outcome is not known with certainty. The experiment s sample space S is the set of all possible outcomes. A random variable is a function

More information

Sources of randomness

Sources of randomness Random Number Generator Chapter 7 In simulations, we generate random values for variables with a specified distribution Ex., model service times using the exponential distribution Generation of random

More information

14 Random Variables and Simulation

14 Random Variables and Simulation 14 Random Variables and Simulation In this lecture note we consider the relationship between random variables and simulation models. Random variables play two important roles in simulation models. We assume

More information

Generating Uniform Random Numbers

Generating Uniform Random Numbers 1 / 41 Generating Uniform Random Numbers Christos Alexopoulos and Dave Goldsman Georgia Institute of Technology, Atlanta, GA, USA 10/13/16 2 / 41 Outline 1 Introduction 2 Some Lousy Generators We Won t

More information

S6880 #6. Random Number Generation #2: Testing RNGs

S6880 #6. Random Number Generation #2: Testing RNGs S6880 #6 Random Number Generation #2: Testing RNGs 1 Testing Uniform RNGs Theoretical Tests Outline 2 Empirical Tests for Independence Gap Tests Runs Test Coupon Collectors Test The Poker Test 3 Other

More information

2008 Winton. Review of Statistical Terminology

2008 Winton. Review of Statistical Terminology 1 Review of Statistical Terminology 2 Formal Terminology An experiment is a process whose outcome is not known with certainty The experiment s sample space S is the set of all possible outcomes. A random

More information

Random Number Generators - a brief assessment of those available

Random Number Generators - a brief assessment of those available Random Number Generators - a brief assessment of those available Anna Mills March 30, 2003 1 Introduction Nothing in nature is random...a thing appears random only through the incompleteness of our knowledge.

More information

How does the computer generate observations from various distributions specified after input analysis?

How does the computer generate observations from various distributions specified after input analysis? 1 How does the computer generate observations from various distributions specified after input analysis? There are two main components to the generation of observations from probability distributions.

More information

How does the computer generate observations from various distributions specified after input analysis?

How does the computer generate observations from various distributions specified after input analysis? 1 How does the computer generate observations from various distributions specified after input analysis? There are two main components to the generation of observations from probability distributions.

More information

Generating Uniform Random Numbers

Generating Uniform Random Numbers 1 / 44 Generating Uniform Random Numbers Christos Alexopoulos and Dave Goldsman Georgia Institute of Technology, Atlanta, GA, USA 10/29/17 2 / 44 Outline 1 Introduction 2 Some Lousy Generators We Won t

More information

B.N.Bandodkar College of Science, Thane. Random-Number Generation. Mrs M.J.Gholba

B.N.Bandodkar College of Science, Thane. Random-Number Generation. Mrs M.J.Gholba B.N.Bandodkar College of Science, Thane Random-Number Generation Mrs M.J.Gholba Properties of Random Numbers A sequence of random numbers, R, R,., must have two important statistical properties, uniformity

More information

Random number generation

Random number generation CE 391F April 4, 2013 ANNOUNCEMENTS Homework 3 due today Homework 4 coming... Announcements Webinar announcement Femke van Wageningen-Kessels from TU Delft will be giving a webinar titled Traffic Flow

More information

Workshop on Heterogeneous Computing, 16-20, July No Monte Carlo is safe Monte Carlo - more so parallel Monte Carlo

Workshop on Heterogeneous Computing, 16-20, July No Monte Carlo is safe Monte Carlo - more so parallel Monte Carlo Workshop on Heterogeneous Computing, 16-20, July 2012 No Monte Carlo is safe Monte Carlo - more so parallel Monte Carlo K. P. N. Murthy School of Physics, University of Hyderabad July 19, 2012 K P N Murthy

More information

Pseudo-Random Numbers Generators. Anne GILLE-GENEST. March 1, Premia Introduction Definitions Good generators...

Pseudo-Random Numbers Generators. Anne GILLE-GENEST. March 1, Premia Introduction Definitions Good generators... 14 pages 1 Pseudo-Random Numbers Generators Anne GILLE-GENEST March 1, 2012 Contents Premia 14 1 Introduction 2 1.1 Definitions............................. 2 1.2 Good generators..........................

More information

Simulation. Where real stuff starts

Simulation. Where real stuff starts 1 Simulation Where real stuff starts ToC 1. What is a simulation? 2. Accuracy of output 3. Random Number Generators 4. How to sample 5. Monte Carlo 6. Bootstrap 2 1. What is a simulation? 3 What is a simulation?

More information

IE 303 Discrete-Event Simulation L E C T U R E 6 : R A N D O M N U M B E R G E N E R A T I O N

IE 303 Discrete-Event Simulation L E C T U R E 6 : R A N D O M N U M B E R G E N E R A T I O N IE 303 Discrete-Event Simulation L E C T U R E 6 : R A N D O M N U M B E R G E N E R A T I O N Review of the Last Lecture Continuous Distributions Uniform distributions Exponential distributions and memoryless

More information

Recall the Basics of Hypothesis Testing

Recall the Basics of Hypothesis Testing Recall the Basics of Hypothesis Testing The level of significance α, (size of test) is defined as the probability of X falling in w (rejecting H 0 ) when H 0 is true: P(X w H 0 ) = α. H 0 TRUE H 1 TRUE

More information

Uniform Random Binary Floating Point Number Generation

Uniform Random Binary Floating Point Number Generation Uniform Random Binary Floating Point Number Generation Prof. Dr. Thomas Morgenstern, Phone: ++49.3943-659-337, Fax: ++49.3943-659-399, tmorgenstern@hs-harz.de, Hochschule Harz, Friedrichstr. 57-59, 38855

More information

Some long-period random number generators using shifts and xors

Some long-period random number generators using shifts and xors ANZIAM J. 48 (CTAC2006) pp.c188 C202, 2007 C188 Some long-period random number generators using shifts and xors Richard P. Brent 1 (Received 6 July 2006; revised 2 July 2007) Abstract Marsaglia recently

More information

2008 Winton. Statistical Testing of RNGs

2008 Winton. Statistical Testing of RNGs 1 Statistical Testing of RNGs Criteria for Randomness For a sequence of numbers to be considered a sequence of randomly acquired numbers, it must have two basic statistical properties: Uniformly distributed

More information

Computer Applications for Engineers ET 601

Computer Applications for Engineers ET 601 Computer Applications for Engineers ET 601 Asst. Prof. Dr. Prapun Suksompong prapun@siit.tu.ac.th Random Variables (Con t) 1 Office Hours: (BKD 3601-7) Wednesday 9:30-11:30 Wednesday 16:00-17:00 Thursday

More information

So far we discussed random number generators that need to have the maximum length period.

So far we discussed random number generators that need to have the maximum length period. So far we discussed random number generators that need to have the maximum length period. Even the increment series has the maximum length period yet it is by no means random How do we decide if a generator

More information

Independent Events. Two events are independent if knowing that one occurs does not change the probability of the other occurring

Independent Events. Two events are independent if knowing that one occurs does not change the probability of the other occurring Independent Events Two events are independent if knowing that one occurs does not change the probability of the other occurring Conditional probability is denoted P(A B), which is defined to be: P(A and

More information

1.1 Linear Congruential Method D. H. Lehmer [15] introduced in 1948 the idea of generating a random number sequence using the following formula: X n+1

1.1 Linear Congruential Method D. H. Lehmer [15] introduced in 1948 the idea of generating a random number sequence using the following formula: X n+1 Testing Pseudo-Random Number Generators Abstract Julian Ortiz C. and Clayton V. Deutsch (jmo1@ualberta.ca - cdeutsch@civil.ualberta.ca) Department of Civil& Environmental Engineering, University of Alberta

More information

the time it takes until a radioactive substance undergoes a decay

the time it takes until a radioactive substance undergoes a decay 1 Probabilities 1.1 Experiments with randomness Wewillusethetermexperimentinaverygeneralwaytorefertosomeprocess that produces a random outcome. Examples: (Ask class for some first) Here are some discrete

More information

UNIT 5:Random number generation And Variation Generation

UNIT 5:Random number generation And Variation Generation UNIT 5:Random number generation And Variation Generation RANDOM-NUMBER GENERATION Random numbers are a necessary basic ingredient in the simulation of almost all discrete systems. Most computer languages

More information

Chi Square Analysis M&M Statistics. Name Period Date

Chi Square Analysis M&M Statistics. Name Period Date Chi Square Analysis M&M Statistics Name Period Date Have you ever wondered why the package of M&Ms you just bought never seems to have enough of your favorite color? Or, why is it that you always seem

More information

Random processes and probability distributions. Phys 420/580 Lecture 20

Random processes and probability distributions. Phys 420/580 Lecture 20 Random processes and probability distributions Phys 420/580 Lecture 20 Random processes Many physical processes are random in character: e.g., nuclear decay (Poisson distributed event count) P (k, τ) =

More information

Pseudo-Random Number Generators

Pseudo-Random Number Generators Unit 41 April 18, 2011 1 Pseudo-Random Number Generators Recall the one-time pad: k = k 1, k 2, k 3... a random bit-string p = p 1, p 2, p 3,... plaintext bits E(p) = p k. We desire long sequences of numbers

More information

11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic

11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic 11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic Bezout s Lemma Let's look at the values of 4x + 6y when x and y are integers. If x is -6 and y is 4 we

More information

Modern Methods of Data Analysis - WS 07/08

Modern Methods of Data Analysis - WS 07/08 Modern Methods of Data Analysis Lecture III (29.10.07) Contents: Overview & Test of random number generators Random number distributions Monte Carlo The terminology Monte Carlo-methods originated around

More information

A TEST OF RANDOMNESS BASED ON THE DISTANCE BETWEEN CONSECUTIVE RANDOM NUMBER PAIRS. Matthew J. Duggan John H. Drew Lawrence M.

A TEST OF RANDOMNESS BASED ON THE DISTANCE BETWEEN CONSECUTIVE RANDOM NUMBER PAIRS. Matthew J. Duggan John H. Drew Lawrence M. Proceedings of the 2005 Winter Simulation Conference M. E. Kuhl, N. M. Steiger, F. B. Armstrong, and J. A. Joines, eds. A TEST OF RANDOMNESS BASED ON THE DISTANCE BETWEEN CONSECUTIVE RANDOM NUMBER PAIRS

More information

Review of Statistics 101

Review of Statistics 101 Review of Statistics 101 We review some important themes from the course 1. Introduction Statistics- Set of methods for collecting/analyzing data (the art and science of learning from data). Provides methods

More information

1: Please compute the Jacobi symbol ( 99

1: Please compute the Jacobi symbol ( 99 SCORE/xx: Math 470 Communications Cryptography NAME: PRACTICE FINAL Please show your work write only in pen. Notes are forbidden. Calculators, all other electronic devices, are forbidden. Brains are encouraged,

More information

Generating Random Variables

Generating Random Variables Generating Random Variables These slides are created by Dr. Yih Huang of George Mason University. Students registered in Dr. Huang's courses at GMU can make a single machine-readable copy and print a single

More information

Simulation. Where real stuff starts

Simulation. Where real stuff starts Simulation Where real stuff starts March 2019 1 ToC 1. What is a simulation? 2. Accuracy of output 3. Random Number Generators 4. How to sample 5. Monte Carlo 6. Bootstrap 2 1. What is a simulation? 3

More information

Some long-period random number generators using shifts and xors

Some long-period random number generators using shifts and xors Introduction Some long-period random number generators using shifts and xors Richard P. Brent MSI & RSISE, ANU Canberra, ACT 0200 CTAC06@rpbrent.com Marsaglia recently proposed a class of uniform random

More information

Pseudo-Random Generators

Pseudo-Random Generators Pseudo-Random Generators Why do we need random numbers? Simulation Sampling Numerical analysis Computer programming (e.g. randomized algorithm) Elementary and critical element in many cryptographic protocols

More information

Pseudo-Random Generators

Pseudo-Random Generators Pseudo-Random Generators Topics Why do we need random numbers? Truly random and Pseudo-random numbers. Definition of pseudo-random-generator What do we expect from pseudorandomness? Testing for pseudo-randomness.

More information

6 Cosets & Factor Groups

6 Cosets & Factor Groups 6 Cosets & Factor Groups The course becomes markedly more abstract at this point. Our primary goal is to break apart a group into subsets such that the set of subsets inherits a natural group structure.

More information

Some long-period random number generators using shifts and xors

Some long-period random number generators using shifts and xors Some long-period random number generators using shifts and xors Richard. P. Brent 2 July 2007 Abstract Marsaglia recently introduced a class of xorshift random number generators (RNGs) with periods 2 n

More information

Lecture 12: Interactive Proofs

Lecture 12: Interactive Proofs princeton university cos 522: computational complexity Lecture 12: Interactive Proofs Lecturer: Sanjeev Arora Scribe:Carl Kingsford Recall the certificate definition of NP. We can think of this characterization

More information

Class 12. Random Numbers

Class 12. Random Numbers Class 12. Random Numbers NRiC 7. Frequently needed to generate initial conditions. Often used to solve problems statistically. How can a computer generate a random number? It can t! Generators are pseudo-random.

More information

The Euclidean Algorithm and Multiplicative Inverses

The Euclidean Algorithm and Multiplicative Inverses 1 The Euclidean Algorithm and Multiplicative Inverses Lecture notes for Access 2009 The Euclidean Algorithm is a set of instructions for finding the greatest common divisor of any two positive integers.

More information

Topics. Pseudo-Random Generators. Pseudo-Random Numbers. Truly Random Numbers

Topics. Pseudo-Random Generators. Pseudo-Random Numbers. Truly Random Numbers Topics Pseudo-Random Generators Why do we need random numbers? Truly random and Pseudo-random numbers. Definition of pseudo-random-generator What do we expect from pseudorandomness? Testing for pseudo-randomness.

More information

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications n-bit unsigned integer representation Represent integer x as sum of powers of 2: If x = n 1 i=0 b i 2 i where each b i

More information

Stream Ciphers. Çetin Kaya Koç Winter / 20

Stream Ciphers. Çetin Kaya Koç   Winter / 20 Çetin Kaya Koç http://koclab.cs.ucsb.edu Winter 2016 1 / 20 Linear Congruential Generators A linear congruential generator produces a sequence of integers x i for i = 1,2,... starting with the given initial

More information

The next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem.

The next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem. CS 70 Discrete Mathematics for CS Fall 2003 Wagner Lecture 10 The next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem.

More information

Random numbers and generators

Random numbers and generators Chapter 2 Random numbers and generators Random numbers can be generated experimentally, like throwing dice or from radioactive decay measurements. In numerical calculations one needs, however, huge set

More information

1 Randomized Computation

1 Randomized Computation CS 6743 Lecture 17 1 Fall 2007 1 Randomized Computation Why is randomness useful? Imagine you have a stack of bank notes, with very few counterfeit ones. You want to choose a genuine bank note to pay at

More information

Random Number Generation. Stephen Booth David Henty

Random Number Generation. Stephen Booth David Henty Random Number Generation Stephen Booth David Henty Introduction Random numbers are frequently used in many types of computer simulation Frequently as part of a sampling process: Generate a representative

More information

Applied Cryptography and Computer Security CSE 664 Spring 2017

Applied Cryptography and Computer Security CSE 664 Spring 2017 Applied Cryptography and Computer Security Lecture 11: Introduction to Number Theory Department of Computer Science and Engineering University at Buffalo 1 Lecture Outline What we ve covered so far: symmetric

More information

Chapter 10. Chapter 10. Multinomial Experiments and. Multinomial Experiments and Contingency Tables. Contingency Tables.

Chapter 10. Chapter 10. Multinomial Experiments and. Multinomial Experiments and Contingency Tables. Contingency Tables. Chapter 10 Multinomial Experiments and Contingency Tables 1 Chapter 10 Multinomial Experiments and Contingency Tables 10-1 1 Overview 10-2 2 Multinomial Experiments: of-fitfit 10-3 3 Contingency Tables:

More information

Uniform and Exponential Random Floating Point Number Generation

Uniform and Exponential Random Floating Point Number Generation Uniform and Exponential Random Floating Point Number Generation Thomas Morgenstern Hochschule Harz, Friedrichstr. 57-59, D-38855 Wernigerode tmorgenstern@hs-harz.de Summary. Pseudo random number generators

More information

Topic Contents. Factoring Methods. Unit 3: Factoring Methods. Finding the square root of a number

Topic Contents. Factoring Methods. Unit 3: Factoring Methods. Finding the square root of a number Topic Contents Factoring Methods Unit 3 The smallest divisor of an integer The GCD of two numbers Generating prime numbers Computing prime factors of an integer Generating pseudo random numbers Raising

More information

Sum-discrepancy test on pseudorandom number generators

Sum-discrepancy test on pseudorandom number generators Sum-discrepancy test on pseudorandom number generators Makoto Matsumoto a,, Takuji Nishimura b a Faculty of Science, Hiroshima University, Hiroshima 739-8526, JAPAN b Faculty of Science, Yamagata University,

More information

CSE 502 Class 11 Part 2

CSE 502 Class 11 Part 2 CSE 502 Class 11 Part 2 Jeremy Buhler Steve Cole February 17 2015 Today: analysis of hashing 1 Constraints of Double Hashing How does using OA w/double hashing constrain our hash function design? Need

More information

INTRODUCTION TO ANALYSIS OF VARIANCE

INTRODUCTION TO ANALYSIS OF VARIANCE CHAPTER 22 INTRODUCTION TO ANALYSIS OF VARIANCE Chapter 18 on inferences about population means illustrated two hypothesis testing situations: for one population mean and for the difference between two

More information

Average-case Analysis for Combinatorial Problems,

Average-case Analysis for Combinatorial Problems, Average-case Analysis for Combinatorial Problems, with s and Stochastic Spanning Trees Mathematical Sciences, Carnegie Mellon University February 2, 2006 Outline Introduction 1 Introduction Combinatorial

More information

Chaos and Liapunov exponents

Chaos and Liapunov exponents PHYS347 INTRODUCTION TO NONLINEAR PHYSICS - 2/22 Chaos and Liapunov exponents Definition of chaos In the lectures we followed Strogatz and defined chaos as aperiodic long-term behaviour in a deterministic

More information

GRE Quantitative Reasoning Practice Questions

GRE Quantitative Reasoning Practice Questions GRE Quantitative Reasoning Practice Questions y O x 7. The figure above shows the graph of the function f in the xy-plane. What is the value of f (f( ))? A B C 0 D E Explanation Note that to find f (f(

More information

Lecture 4: Two-point Sampling, Coupon Collector s problem

Lecture 4: Two-point Sampling, Coupon Collector s problem Randomized Algorithms Lecture 4: Two-point Sampling, Coupon Collector s problem Sotiris Nikoletseas Associate Professor CEID - ETY Course 2013-2014 Sotiris Nikoletseas, Associate Professor Randomized Algorithms

More information

Entropy. Probability and Computing. Presentation 22. Probability and Computing Presentation 22 Entropy 1/39

Entropy. Probability and Computing. Presentation 22. Probability and Computing Presentation 22 Entropy 1/39 Entropy Probability and Computing Presentation 22 Probability and Computing Presentation 22 Entropy 1/39 Introduction Why randomness and information are related? An event that is almost certain to occur

More information

CS1800: Strong Induction. Professor Kevin Gold

CS1800: Strong Induction. Professor Kevin Gold CS1800: Strong Induction Professor Kevin Gold Mini-Primer/Refresher on Unrelated Topic: Limits This is meant to be a problem about reasoning about quantifiers, with a little practice of other skills, too

More information

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer? Chapter 3: Theory of Modular Arithmetic 25 SECTION C Solving Linear Congruences By the end of this section you will be able to solve congruence equations determine the number of solutions find the multiplicative

More information

CS 360, Winter Morphology of Proof: An introduction to rigorous proof techniques

CS 360, Winter Morphology of Proof: An introduction to rigorous proof techniques CS 30, Winter 2011 Morphology of Proof: An introduction to rigorous proof techniques 1 Methodology of Proof An example Deep down, all theorems are of the form If A then B, though they may be expressed

More information

The t-distribution. Patrick Breheny. October 13. z tests The χ 2 -distribution The t-distribution Summary

The t-distribution. Patrick Breheny. October 13. z tests The χ 2 -distribution The t-distribution Summary Patrick Breheny October 13 Patrick Breheny Biostatistical Methods I (BIOS 5710) 1/25 Introduction Introduction What s wrong with z-tests? So far we ve (thoroughly!) discussed how to carry out hypothesis

More information

Computer Applications for Engineers ET 601

Computer Applications for Engineers ET 601 Computer Applications for Engineers ET 601 Asst. Prof. Dr. Prapun Suksompong prapun@siit.tu.ac.th Random Variables (Con t) 1 Office Hours: (BKD 3601-7) Wednesday 9:30-11:30 Wednesday 16:00-17:00 Thursday

More information

Computer Science Foundation Exam

Computer Science Foundation Exam Computer Science Foundation Exam May 6, 2016 Section II A DISCRETE STRUCTURES NO books, notes, or calculators may be used, and you must work entirely on your own. SOLUTION Question Max Pts Category Passing

More information

AN INTRODUCTION TO MATHEMATICAL CRYPTOGRAPHY ERRATA FOR THE SECOND EDITION

AN INTRODUCTION TO MATHEMATICAL CRYPTOGRAPHY ERRATA FOR THE SECOND EDITION AN INTRODUCTION TO MATHEMATICAL CRYPTOGRAPHY ERRATA FOR THE SECOND EDITION JEFFREY HOFFSTEIN, JILL PIPHER, JOSEPH H. SILVERMAN Acknowledgements We would like to thank the following people who have sent

More information

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya BBM 205 Discrete Mathematics Hacettepe University http://web.cs.hacettepe.edu.tr/ bbm205 Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya Resources: Kenneth Rosen,

More information

Introduction to Survey Analysis!

Introduction to Survey Analysis! Introduction to Survey Analysis! Professor Ron Fricker! Naval Postgraduate School! Monterey, California! Reading Assignment:! 2/22/13 None! 1 Goals for this Lecture! Introduction to analysis for surveys!

More information

Lecture 5: Two-point Sampling

Lecture 5: Two-point Sampling Randomized Algorithms Lecture 5: Two-point Sampling Sotiris Nikoletseas Professor CEID - ETY Course 2017-2018 Sotiris Nikoletseas, Professor Randomized Algorithms - Lecture 5 1 / 26 Overview A. Pairwise

More information

Big Data Analysis with Apache Spark UC#BERKELEY

Big Data Analysis with Apache Spark UC#BERKELEY Big Data Analysis with Apache Spark UC#BERKELEY This Lecture: Relation between Variables An association A trend» Positive association or Negative association A pattern» Could be any discernible shape»

More information

Lecture 5: Random numbers and Monte Carlo (Numerical Recipes, Chapter 7) Motivations for generating random numbers

Lecture 5: Random numbers and Monte Carlo (Numerical Recipes, Chapter 7) Motivations for generating random numbers Lecture 5: Random numbers and Monte Carlo (Numerical Recipes, Chapter 7) Motivations for generating random numbers To sample a function in a statistically controlled manner (i.e. for Monte Carlo integration)

More information

CS280, Spring 2004: Final

CS280, Spring 2004: Final CS280, Spring 2004: Final 1. [4 points] Which of the following relations on {0, 1, 2, 3} is an equivalence relation. (If it is, explain why. If it isn t, explain why not.) Just saying Yes or No with no

More information

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications casting out 3s Theorem: A positive integer n is divisible by 3 if and only if the sum of its decimal digits is divisible

More information

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer? Chapter 3: Theory of Modular Arithmetic 25 SECTION C Solving Linear Congruences By the end of this section you will be able to solve congruence equations determine the number of solutions find the multiplicative

More information

Monte Carlo Methods. Jesús Fernández-Villaverde University of Pennsylvania

Monte Carlo Methods. Jesús Fernández-Villaverde University of Pennsylvania Monte Carlo Methods Jesús Fernández-Villaverde University of Pennsylvania 1 Why Monte Carlo? From previous chapter, we want to compute: 1. Posterior distribution: π ³ θ Y T,i = f(y T θ,i)π (θ i) R Θ i

More information

String Matching. Thanks to Piotr Indyk. String Matching. Simple Algorithm. for s 0 to n-m. Match 0. for j 1 to m if T[s+j] P[j] then

String Matching. Thanks to Piotr Indyk. String Matching. Simple Algorithm. for s 0 to n-m. Match 0. for j 1 to m if T[s+j] P[j] then String Matching Thanks to Piotr Indyk String Matching Input: Two strings T[1 n] and P[1 m], containing symbols from alphabet Σ Goal: find all shifts 0 s n-m such that T[s+1 s+m]=p Example: Σ={,a,b,,z}

More information

Random Numbers. Pierre L Ecuyer

Random Numbers. Pierre L Ecuyer 1 Random Numbers Pierre L Ecuyer Université de Montréal, Montréal, Québec, Canada Random numbers generators (RNGs) are available from many computer software libraries. Their purpose is to produce sequences

More information

Statistics, Data Analysis, and Simulation SS 2013

Statistics, Data Analysis, and Simulation SS 2013 Mainz, May 2, 2013 Statistics, Data Analysis, and Simulation SS 2013 08.128.730 Statistik, Datenanalyse und Simulation Dr. Michael O. Distler 2. Random Numbers 2.1 Why random numbers:

More information

2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer.

2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer. CHAPTER 2 INTRODUCTION TO NUMBER THEORY ANSWERS TO QUESTIONS 2.1 A nonzero b is a divisor of a if a = mb for some m, where a, b, and m are integers. That is, b is a divisor of a if there is no remainder

More information

Statistics for Data Analysis. Niklaus Berger. PSI Practical Course Physics Institute, University of Heidelberg

Statistics for Data Analysis. Niklaus Berger. PSI Practical Course Physics Institute, University of Heidelberg Statistics for Data Analysis PSI Practical Course 2014 Niklaus Berger Physics Institute, University of Heidelberg Overview You are going to perform a data analysis: Compare measured distributions to theoretical

More information

cse 311: foundations of computing Fall 2015 Lecture 11: Modular arithmetic and applications

cse 311: foundations of computing Fall 2015 Lecture 11: Modular arithmetic and applications cse 311: foundations of computing Fall 2015 Lecture 11: Modular arithmetic and applications arithmetic mod 7 a + 7 b = (a + b) mod 7 a 7 b = (a b) mod 7 5 6 0 1 2 4 3 + 0 1 2 3 4 5 6 0 0 1 2 3 4 5 6 1

More information

AP Statistics Cumulative AP Exam Study Guide

AP Statistics Cumulative AP Exam Study Guide AP Statistics Cumulative AP Eam Study Guide Chapters & 3 - Graphs Statistics the science of collecting, analyzing, and drawing conclusions from data. Descriptive methods of organizing and summarizing statistics

More information