Random number generators and random processes. Statistics and probability intro. Peg board example. Peg board example. Notes. Eugeniy E.

Similar documents
Random Number Generation. Stephen Booth David Henty

Root finding. Eugeniy E. Mikhailov. Lecture 06. The College of William & Mary. Eugeniy Mikhailov (W&M) Practical Computing Lecture 06 1 / 10

Root finding. Root finding problem. Root finding problem. Root finding problem. Notes. Eugeniy E. Mikhailov. Lecture 05. Notes

Root finding. Eugeniy E. Mikhailov. Lecture 05. The College of William & Mary. Eugeniy Mikhailov (W&M) Practical Computing Lecture 05 1 / 10

Hands-on Generating Random

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?

( x) ( ) F ( ) ( ) ( ) Prob( ) ( ) ( ) X x F x f s ds

2 Random Variable Generation

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

Random number generators

B. Maddah ENMG 622 Simulation 11/11/08

A Repetition Test for Pseudo-Random Number Generators

Review of Statistical Terminology

Class 12. Random Numbers

Generating pseudo- random numbers

4.5 Applications of Congruences

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

Lecture 2 : CS6205 Advanced Modeling and Simulation

Computer Applications for Engineers ET 601

Uniform Random Number Generators

Lecture 20. Randomness and Monte Carlo. J. Chaudhry. Department of Mathematics and Statistics University of New Mexico

2008 Winton. Review of Statistical Terminology

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

Random Number Generation. CS1538: Introduction to simulations

Computer Applications for Engineers ET 601

UNIT 5:Random number generation And Variation Generation

Computer Intensive Methods in Mathematical Statistics

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

Scientific Computing: Monte Carlo

Algorithms and Networking for Computer Games

The Monte Carlo method what and how?

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

Statistics, Data Analysis, and Simulation SS 2013

Systems Simulation Chapter 7: Random-Number Generation

Stream Ciphers. Çetin Kaya Koç Winter / 20

Introduction. Microscopic Theories of Nuclear Structure, Dynamics and Electroweak Currents June 12-30, 2017, ECT*, Trento, Italy

Random number generation

14 Random Variables and Simulation

Simulation. Version 1.1 c 2010, 2009, 2001 José Fernando Oliveira Maria Antónia Carravilla FEUP

3F1 Information Theory, Lecture 3

Lecture Notes. Advanced Discrete Structures COT S

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

Statistische Methoden der Datenanalyse. Kapitel 3: Die Monte-Carlo-Methode

Physics 403. Segev BenZvi. Monte Carlo Techniques. Department of Physics and Astronomy University of Rochester

Simulation. Where real stuff starts

Random numbers and generators

Slides 3: Random Numbers

Robotics. Lecture 4: Probabilistic Robotics. See course website for up to date information.

Random numbers and random number generators

Monte Carlo Techniques

Lehmer Random Number Generators: Introduction

Appendix C: Generation of Pseudo-Random Numbers

Generating Random Variables

Physics 403 Monte Carlo Techniques

Lecture 9 Classification of States

Uniform random numbers generators

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

arxiv:hep-lat/ v2 10 Aug 1993

Sources of randomness

METHODS FOR GENERATION OF RANDOM NUMBERS IN PARALLEL STOCHASTIC ALGORITHMS FOR GLOBAL OPTIMIZATION

Uniform Random Binary Floating Point Number Generation

Algorithms lecture notes 1. Hashing, and Universal Hash functions

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

Lecture 10 Oct. 3, 2017

Pseudo-Random Generators

Lecture 11 - Basic Number Theory.

Pseudo-Random Generators

Modern Methods of Data Analysis - WS 07/08

Random Number Generators

Outline. policies for the first part. with some potential answers... MCS 260 Lecture 10.0 Introduction to Computer Science Jan Verschelde, 9 July 2014

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

20.1 2SAT. CS125 Lecture 20 Fall 2016

Chapter 4: Monte Carlo Methods. Paisan Nakmahachalasint

Pseudo-random Number Generation. Qiuliang Tang

Lecture 5: Two-point Sampling

Monte Carlo methods for kinetic equations

Signal types. Signal characteristics: RMS, power, db Probability Density Function (PDF). Analogue-to-Digital Conversion (ADC).

Randomized algorithms. Inge Li Gørtz

Numerical methods for lattice field theory

CS145: Probability & Computing Lecture 24: Algorithms

TOTAL JITTER MEASUREMENT THROUGH THE EXTRAPOLATION OF JITTER HISTOGRAMS

Random Number Generation: RNG: A Practitioner s Overview

Chapter 7 Random Numbers

1 Notes and Directions on Dirac Notation

Numerical Methods I Monte Carlo Methods

The problems that follow illustrate the methods covered in class. They are typical of the types of problems that will be on the tests.

From Random Numbers to Monte Carlo. Random Numbers, Random Walks, Diffusion, Monte Carlo integration, and all that

In case (1) 1 = 0. Then using and from the previous lecture,

Tae-Soo Kim and Young-Kyun Yang

Efficient Pseudorandom Generators Based on the DDH Assumption

Motivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis

CDM. (Pseudo-) Randomness. Klaus Sutner Carnegie Mellon University Fall 2004

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

Organization. I MCMC discussion. I project talks. I Lecture.

Random Number Generators - a brief assessment of those available

Lesson 19: Matlab Tools for Teletraffic Engineering

Department of Electrical- and Information Technology. ETS061 Lecture 3, Verification, Validation and Input

Lecture 31: Miller Rabin Test. Miller Rabin Test

16.4. Power Series. Introduction. Prerequisites. Learning Outcomes

Transcription:

Random number generators and random processes Eugeniy E. Mikhailov The College of William & Mary Lecture 11 Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 1 / 11 Statistics and probability intro Mathematical and physical definition of probability (p) of event x N x p x = lim N total N total where N x N total the number of registered event x the total number of all events Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 2 / 11

Example of 10 4 balls runs over 40 layers of nails x=pegboard(10^4, 40); hist(x, [-25:25]); 1400 1200 1000 800 600 400 200 0-20 -10 0 10 20 Resulting distribution is Gaussian Probability for occurrence of the real number It is well known that interval [0..1] has infinite amount of reals numbers (as well as any other non zero interval). So there is very little or may be zero chance that event will repeat or even happen. Since we cannot run number of tests. In this case we should speak about probability density p(x). The best way to estimate it is from a histogram. Run your N tests with numbers distributed between 0 and 1. Split your interval at m bins and calculate number of events when you hit each bin h(x b ). Plot this vs bin positions. Easy to do with Matlab r = rand(1, N); hist(r, m); Then p(x) = lim N,m h(x b nearest to x) N Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 4 / 11 Uniform random distribution r = rand(1, 10000); hist(r, 10); r = rand(1, 10000); hist(r, 100); 1200 1000 800 600 400 200 00 0.2 0.4 0.6 0.8 1 140 120 100 80 60 40 20 00 0.2 0.4 0.6 0.8 1 Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 5 / 11 Random number generators How can a computer, which is very accurate, precise, and deterministic, generate random numbers? It cannot! Instead we can generate a sequence of pseudo random numbers. By pseudo we mean that starting from the same initial conditions the computer will generate the same sequence of numbers (very handy for debugging). But otherwise it will look like random numbers and will have statistical properties of random numbers. Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 6 / 11

Linear Congruential Generator (LCG) Recursive formula r i+1 = (ar i + c) mod m here m the modulus a multiplier, 0 < a < m c increment, c c < m r 1 seed value, 0 r 1 < m All pseudo random generators have a period and this one is no exception. Note that once r i repeat one of the previous values the sequence will restart. This one can have at most a period of m distinct numbers (0..m). Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 7 / 11 Linear Congruential Generator (LCG) continued Bad choice of a, c, m will lead to even shorter periods. Example m = 10, a = 2, c = 1,r 1 = 1 r = [1, 3, 7, 5, 1] While the LCG has advantage of speed and simplicity. Do not use the LCG whenever your money or reputation are at stake! While Matlab does not use LCG, many other programming languages use it as default in their libraries so be aware of it. Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 8 / 11 Random number generators period Even the best pseudo random generators cannot have a period larger than 2 B, where B is number of memory bits. Can you prove it? While the period can be huge its not infinite. For example for Matlab R2007a the period is 2 19937 1. Why bother? Recall that for example error of the Monte Carlo integration method is 1/ N. This holds true only when N < than the period of random number generator (T ). Otherwise the MC method cannot give uncertainty better than 1/ T. Further increase of the number of random points will not bring any extra improvement. Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 9 / 11 How to check the random generator Generally it is uneasy and probably impossible. However for us only statistical properties are of importance. So the easiest is to check that integral deviation calculated with Monte Carlo algorithm drops as 1/ N. Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 10 / 11

Simple LCG check Let s see how the LCG will look with very bad coefficient m = 10, a = 2, c = 1,r 1 = 1 10 0 rand lcg function r=... lcgrand(nrows,ncols,... a,c,m, seed) 10 1 10 2 10 3 10 4 10 5 10 1 10 2 10 3 10 4 10 5 10 6 Lines are from MC with rand and line-crosses for lcgrand(nrows, Ncols, 2,1,10); r=zeros(nrows, Ncols); r(1)=seed; cntr=1; for i=2:nrows*ncols; r(i)= mod( (a*r(i-1)+c), m); end r=r/(m-1); %normalization end check_lcgrand Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 11 / 11