Random Numbers CSE 331 Section 2 James Daly. Randomness Most algorithms we’ve talked about have been deterministic The same inputs always give the same.

Slides:



Advertisements
Similar presentations
Generating Random Numbers
Advertisements

Random Number Generation Graham Netherton Logan Stelly.
Random variables 1. Note  there is no chapter in the textbook that corresponds to this topic 2.
Random Number Generation. Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine,
History of Random Number Generators Bob De Vivo Probability and Statistics Summer 2005.
Random Numbers. Two Types of Random Numbers 1.True random numbers: True random numbers are generated in non- deterministic ways. They are not predictable.
Random number generation Algorithms and Transforms to Univariate Distributions.
Fundamental Structures of Computer Science April 29, 2003.
Computability and Complexity 20-1 Computability and Complexity Andrei Bulatov Random Sources.
Random Number Generators. Why do we need random variables? random components in simulation → need for a method which generates numbers that are random.
Stream cipher diagram + + Recall: One-time pad in Chap. 2.
Genetic Algorithms Can Be Used To Obtain Good Linear Congruential Generators Presented by Ben Sproat.
Computers and Random Numbers Andrew Ross Math Dept., Eastern Michigan Univ
Pseudorandom Number Generators
1 Analysis of the Linux Random Number Generator Zvi Gutterman, Benny Pinkas, and Tzachy Reinman.
CSE 326 Randomized Data Structures David Kaplan Dept of Computer Science & Engineering Autumn 2001.
K. Desch – Statistical methods of data analysis SS10
CSCE Monte Carlo Methods When you can’t do the math, simulate the process with random numbers Numerical integration to get areas/volumes Particle.
Randomized Algorithms. Introduction Algorithm uses a random number to make at least one decision Running time depends on input and random numbers generated.
Random numbers in Python Nobody knows what’s next...
Chapter 8 – Introduction to Number Theory Prime Numbers
Finite probability space set  (sample space) function P:  R + (probability distribution)  P(x) = 1 x 
Random Thoughts 2012 (COMP 066) Jan-Michael Frahm Jared Heinly.
APPENDIX D RANDOM NUMBER GENERATION
Genome Sciences 373 Genome Informatics Quiz Section 9 May
15-853Page :Algorithms in the Real World Generating Random and Pseudorandom Numbers.
CSE 321 Discrete Structures Winter 2008 Lecture 10 Number Theory: Primality.
Pseudorandom Number Generators. Randomness and Security Many cryptographic protocols require the parties to generate random numbers. All the hashing algorithms.
Cryptography and Network Security Chapter 7 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Pseudo-random Number Generation Qiuliang Tang. Random Numbers in Cryptography ► The keystream in the one-time pad ► The secret key in the DES encryption.
RSA Parameter Generation Bob needs to: - find 2 large primes p,q - find e s.t. gcd(e, Á (pq))=1 Good news: - primes are fairly common: there are about.
Chapter 14 Randomized algorithms Introduction Las Vegas and Monte Carlo algorithms Randomized Quicksort Randomized selection Testing String Equality Pattern.
MA/CSSE 473 Day 08 Randomized Primality Testing Carmichael Numbers Miller-Rabin test.
Random-Number Generation Andy Wang CIS Computer Systems Performance Analysis.

CS 450 – Modeling and Simulation Dr. X. Topics What Does Randomness Mean? Randomness in games Generating Random Values Random events in real life: measuring.
Analyzing and Testing a justified Prime Number Jeong-kyu YANG Seok-kyu Kang ( Mid-term Presentation )
Random Number Generators 1. Random number generation is a method of producing a sequence of numbers that lack any discernible pattern. Random Number Generators.
Pseudo-random generators Random Number Generating There are three types of generators table look-up generators hardware generators algorithmic (software)
CS221 Random Numbers. Random numbers are often very important in programming Suppose you are writing a program to play the game of roulette The numbers.
Random Number Generator. Random number Random number: Uniform distribution on [0,1] Random device: dice, coin -> cannot generate the equal sequence.
PRNGs Pseudo-random number generation. Randomness and Cryptography Randomness and pseudo-randomness are useful in cryptography: –To generate random and.
9/22/15UB Fall 2015 CSE565: S. Upadhyaya Lec 7.1 CSE565: Computer Security Lecture 7 Number Theory Concepts Shambhu Upadhyaya Computer Science & Eng. University.
Random numbers in C++ Nobody knows what’s next....
Random Numbers RANDOM VS PSEUDO RANDOM. Truly Random numbers  From Wolfram: “A random number is a number chosen as if by chance from some specified distribution.
CS 615: Design & Analysis of Algorithms Chapter 7: Randomized Algorithms (Weiss Chap.: 10.4)
6.3 Primality Testing. p2. (1) Prime numbers 1. How to generate large prime numbers? (1) Generate as candidate a random odd number n of appropriate size.
G. Cowan Lectures on Statistical Data Analysis Lecture 5 page 1 Statistical Data Analysis: Lecture 5 1Probability, Bayes’ theorem 2Random variables and.
Chapter 7 – Confidentiality Using Symmetric Encryption.
Chapter 1 Algorithms with Numbers. Bases and Logs How many digits does it take to represent the number N >= 0 in base 2? With k digits the largest number.
MA/CSSE 473 Day 10 Primality Testing. MA/CSSE 473 Day 10 In-class exam: Friday, Sept 28 –You may bring a two-sided 8.5x11 inch piece of paper containing.
MA/CSSE 473 Day 09 Modular Division Revisited Fermat's Little Theorem Primality Testing.
0 Simulation Modeling and Analysis: Input Analysis 7 Random Numbers Ref: Law & Kelton, Chapter 7.
CS 115 Lecture 9 Augmented assignment; Boolean logic; random numbers Taken from notes by Dr. Neil Moore.
Chapter 3 Generating Uniform Random Variables. In any kind of simulation, we need data, or we have to produce them. Especially in Monte Marco simulation.
1.  How does the computer generate observations from various distributions specified after input analysis?  There are two main components to the generation.
Key Wrap Algorithm.
10.Deterministic Randomness 1.Random Sequences Random Sequences A sequence of numbers r 1, r 2,... is random if there are no discernible patterns.
Generating Random Numbers
Material in the textbook on pages
A cryptographically secure pseudorandom number generator for Julia
Random numbers Taken from notes by Dr. Neil Moore
Random Number Generation
Random-Number Generation
CS 475/575 Slide set 4 M. Overstreet Old Dominion University
Computing and Statistical Data Analysis Stat 3: The Monte Carlo Method
Cryptography and Network Security Chapter 7
Computer Simulation Techniques Generating Pseudo-Random Numbers
Generating Random and Pseudorandom Numbers
Generating Random and Pseudorandom Numbers
Presentation transcript:

Random Numbers CSE 331 Section 2 James Daly

Randomness Most algorithms we’ve talked about have been deterministic The same inputs always give the same result Sometimes we want different results Many games Cards for poker, blackjack, etc Number for roulette Dice for craps, Monopoly, Settlers of Catan Pick an item arbitrarily Pivot for quicksort

Random Numbers Truly random numbers – use physical phenomenon Dice / Coins Atmospheric noise Radioactive decay Pseudo-random numbers – sequence generated from a key (seed) Not actually random

True Randomness Many measurable phenomenon happen randomly A radioactive atom may or may not decay The least significant bit of the clock when the user presses a key Takes a long time to fill up Blocks or stalls if you need a lot of it /dev/random on Unix-based systems

Random.org Website that generates random numbers Uses atmospheric noise picked up with a radio Limited quota

Pseudorandom numbers Generates a sequence on numbers according to an algorithm Starts with a seed value Often based on the system clock Be careful creating several in a row Using the same seed generates the same sequence Allows for a simulation to be repeated Ex: Get the same series of pieces in Tetris

Potential problems Given enough time, the sequence will repeat The period may be shorter than expected on certain inputs Some values may be correlated Capable of predicting upcoming numbers Numbers may not be uniformly distributed Certain numbers show up more often

Linear Congruential Generator

Very sensitive to the choices of constants c and m must be relatively prime a – 1 must be divisible by all prime factors of m a – 1 must be a multiple of 4 if m is too Otherwise it will not use the full period Could still have other problems

RANDU

Lehmer RNG Another LCG with c = 0 Recommended constants m = (a Mersenne prime) a = 48271

Other LCGs: rand48 Equivalent implementation for glibc and Java Uses m = 2 48, a = , c = 11 Only returns the 32 high order bits instead of all 48 bits Very long period

Mersenne Twister Default PRNG for Python, Ruby, and Matlab Uses a matrix recurrence Advantages Very long period ( – 1) Good distribution Disadvantages Fairly slow Very large state space Description is outside the scope of this class

Primality Testing

Fermat’s Lesser Theorem If p is prime and 0 < a < p, then a p-1 = 1 (mod p) If a n-1 ≠ 1 (mod n) then n must be composite We call a a Fermat witness to the compositeness of n Otherwise n is probably prime We call a a Fermat liar if n is actually composite

Testing In general, at least half of all a are witnesses to n’s compositeness If we try k trials, the probability of getting a false positive is at most (1/2) k If we do 50 trials, probability is at most 1:2 50 Roughly one in one quadrillion chance More likely to have a hardware error than false claim Very conservative except for the Carmichael numbers