Random Number Generators Jake Blanchard Spring 2010 Uncertainty Analysis for Engineers1.

Slides:



Advertisements
Similar presentations
Random Processes Introduction (2)
Advertisements

RSLAB-NTU Lab for Remote Sensing Hydrology and Spatial Modeling 1 An Introduction to R Pseudo Random Number Generation (PRNG) Prof. Ke-Sheng Cheng Dept.
Generating Random Numbers
Uncertainty in fall time surrogate Prediction variance vs. data sensitivity – Non-uniform noise – Example Uncertainty in fall time data Bootstrapping.
Random variables 1. Note  there is no chapter in the textbook that corresponds to this topic 2.
Slide deck by Dr. Greg Reese Miami University MATLAB An Introduction With Applications, 5 th Edition Dr. Amos Gilat The Ohio State University Chapter 3.
Random Number Generation. Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine,
Materials for Lecture 11 Chapters 3 and 6 Chapter 16 Section 4.0 and 5.0 Lecture 11 Pseudo Random LHC.xls Lecture 11 Validation Tests.xls Next 4 slides.
Review of Basic Probability and Statistics
Computational statistics 2009 Random walk. Computational statistics 2009 Random walk with absorbing barrier.
Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),
Fall 2006 – Fundamentals of Business Statistics 1 Chapter 6 Introduction to Sampling Distributions.
Generating Continuous Random Variables some. Quasi-random numbers So far, we learned about pseudo-random sequences and a common method for generating.
Random Number Generation
Analysis of Simulation Input.. Simulation Machine n Simulation can be considered as an Engine with input and output as follows: Simulation Engine Input.
Hashing General idea: Get a large array
Propagation of Uncertainty Jake Blanchard Spring 2010 Uncertainty Analysis for Engineers1.
Random-Number Generation. 2 Properties of Random Numbers Random Number, R i, must be independently drawn from a uniform distribution with pdf: Two important.
Fall 2011 CSC 446/546 Part 6: Random Number Generation.
Lecture (16) Introduction to Stochastic Hydrology.
ETM 607 – Random Number and Random Variates
Sampling The sampling errors are: for sample mean
Ch4: 4.3The Normal distribution 4.4The Exponential Distribution.
1 Lesson 3: Choosing from distributions Theory: LLN and Central Limit Theorem Theory: LLN and Central Limit Theorem Choosing from distributions Choosing.
CPSC 531: RN Generation1 CPSC 531:Random-Number Generation Instructor: Anirban Mahanti Office: ICT Class Location:
Chapter 7 Random-Number Generation
Tests for Random Numbers Dr. Akram Ibrahim Aly Lecture (9)
Module 1: Statistical Issues in Micro simulation Paul Sousa.
Basic Concepts in Number Theory Background for Random Number Generation 1.For any pair of integers n and m, m  0, there exists a unique pair of integers.
Random Number Generators 1. Random number generation is a method of producing a sequence of numbers that lack any discernible pattern. Random Number Generators.
Monte Carlo Methods So far we have discussed Monte Carlo methods based on a uniform distribution of random numbers on the interval [0,1] p(x) = 1 0  x.
Section 5.4 Sampling Distributions and the Central Limit Theorem Larson/Farber 4th ed.
Chapter 7 Sampling and Sampling Distributions ©. Simple Random Sample simple random sample Suppose that we want to select a sample of n objects from a.
Sample Variability Consider the small population of integers {0, 2, 4, 6, 8} It is clear that the mean, μ = 4. Suppose we did not know the population mean.
Discrete Distribution Functions Jake Blanchard Spring 2010 Uncertainty Analysis for Engineers1.
Continuous Random Variables Lecture 25 Section Mon, Feb 28, 2005.
Selecting Input Probability Distribution. Simulation Machine Simulation can be considered as an Engine with input and output as follows: Simulation Engine.
Techniques in Signal Processing CSC 508 Generating Random Numbers with a Computer.
Continuous Random Variables Lecture 24 Section Tue, Mar 7, 2006.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Random Number Generator. Random number Random number: Uniform distribution on [0,1] Random device: dice, coin -> cannot generate the equal sequence.
Exam 2: Rules Section 2.1 Bring a cheat sheet. One page 2 sides. Bring a calculator. Bring your book to use the tables in the back.
Latin Hypercube Sampling Example Jake Blanchard Spring 2010 Uncertainty Analysis for Engineers1.
Fast calculation methods. Addition  Add 137,95 Solution: = (137-5)+100= = 232.
Continuous Random Variables Lecture 22 Section Mon, Feb 25, 2008.
RNGs Using Integer Array Shuffling with the HP Prime
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 Sampling distributions The probability distribution of a statistic is called a sampling distribution. : the sampling distribution of the mean.
Continuous Random Variables Lecture 26 Section Mon, Mar 5, 2007.
§2.The hypothesis testing of one normal population.
Continuous Random Variables Lecture 24 Section Tue, Oct 18, 2005.
0 Simulation Modeling and Analysis: Input Analysis 7 Random Numbers Ref: Law & Kelton, Chapter 7.
Module 9.4 Random Numbers from Various Distributions -MC requires the use of unbiased random numbers.
MONTE CARLO METHOD DISCRETE SIMULATION RANDOM NUMBER GENERATION Chapter 3 : Random Number Generation.
Chapter 4 Particular Methods for Non- Uniform Random Variables.
Sampling and Sampling Distributions
Ch5.4 Central Limit Theorem
Continuous Random Variables
Spatial Online Sampling and Aggregation
Chapter 7 Random Number Generation
Chapter 7 Random-Number Generation
CH 9.2 : Hash Tables Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and.
CH 9.2 : Hash Tables Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and.
EM for Inference in MV Data
Continuous Random Variables
Continuous Random Variables
Continuous Random Variables
EM for Inference in MV Data
The Binomial Distributions
Continuous Random Variables
Presentation transcript:

Random Number Generators Jake Blanchard Spring 2010 Uncertainty Analysis for Engineers1

A Little History Initial random number generators were congruential For example, a=13, c=0, m=31, x 0 =1 Uncertainty Analysis for Engineers2

Congruential Operators Result is integers between 1 and 30 To get U(0,1), divide by m (31) This gives.0323,.4194,.4516, etc. This gives just 30 possible floating point numbers Uncertainty Analysis for Engineers3

Congruential Algorithms Years ago, IBM mainframes use a=65539, c=0, m=2 31 because it was very fast But it has issues – consecutive numbers are correlated For example, suppose we want to generate random points in a cube. We would use 3 consecutive values for the x, y, z coordinates of a random point (See ssp script) Uncertainty Analysis for Engineers4

Matlab Matlab has 3 prominent functions: rand, randn, and randi Until 1995, rand was congruential (a=7 5 =16807, c=0, m= ) This repeats every 2 billion numbers (roughly) (see mcg script) Uncertainty Analysis for Engineers5

Shuffling This Matlab routine still has correlation among consecutive numbers For example, if x<10 -6, next number will be less than To avoid this, shuffle numbers (Matlab didn’t do this) ◦ Start by storing 32 random numbers ◦ When routine is called, randomly select which of the 32 to use and replace with next number in sequence Uncertainty Analysis for Engineers6

New Matlab Algorithm Matlab now uses a look up algorithm Not congruential, no multiplication or division, produces floating point directly Uses 35 words of memory 32 represent cached floating point numbers – 0<z<1 Last three contain index i – 0<i<31, integer j, and borrowflag b Subscripts are modulo 32 Uncertainty Analysis for Engineers7

New Matlab Algorithm b is used to make sure z is positive Period is Small modifications make period Uncertainty Analysis for Engineers8

Repeatability In new Matlab session, the first output from rand is always Matlab will let you repeat a sequence at any time defaultStream=RandStream.getDefaultStream; savedState = defaultStream.State; u1 = rand(1,5) defaultStream.State = savedState; u2 = rand(1,5) Uncertainty Analysis for Engineers9

Normal Deviates One approach is to use sum(rand(m,n,12),3)-6 This adds the 12 uniform deviates for each number, yielding something approximating a normal deviate with mean of 0 and variance of 1 Uncertainty Analysis for Engineers10

Normal Deviates Alternative is rejection method ◦ Generate uniform random numbers in 2 by 2 square and reject points outside unit circle ◦ For accepted points, ◦ Result is 2 normally distributed random numbers Uncertainty Analysis for Engineers11

Newer Matlab Algorithm Divide pdf into rectangles of equal area Randomly sample integer to pick rectangle and then see if u(-1,1) falls within rectangle If u is in jth section, then u*z is a normal deviate Otherwise, reject Uncertainty Analysis for Engineers12

Matlab Algorithm Uncertainty Analysis for Engineers13

Other Distributions If cdf can be inverted, you can sample them directly See later slides Uncertainty Analysis for Engineers14