1 Random Number Generation H Plan: –Introduce basics of RN generation –Define concepts and terminology –Introduce RNG methods u Linear Congruential Generator.

Slides:



Advertisements
Similar presentations
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.
Advertisements

PARALLEL RANDOM NUMBER GENERATION
Generating Random Numbers
Random Number Generation. Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine,
 1  Outline  generation of random variates  convolution  composition  acceptance/rejection  generation of uniform(0, 1) random variates  linear.
Random number generation Algorithms and Transforms to Univariate Distributions.
CDA6530: Performance Models of Computers and Networks Chapter 5: Generating Random Number and Random Variables TexPoint fonts used in EMF. Read the TexPoint.
1 Statistical Inference H Plan: –Discuss statistical methods in simulations –Define concepts and terminology –Traditional approaches: u Hypothesis testing.
Random Number Generators. Why do we need random variables? random components in simulation → need for a method which generates numbers that are random.
Simulation Where real stuff starts. ToC 1.What, transience, stationarity 2.How, discrete event, recurrence 3.Accuracy of output 4.Monte Carlo 5.Random.
Stream cipher diagram + + Recall: One-time pad in Chap. 2.
Simulation Modeling and Analysis
Generating Random Numbers
Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),
Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),
Descriptive statistics Experiment  Data  Sample Statistics Experiment  Data  Sample Statistics Sample mean Sample mean Sample variance Sample variance.
Random Number Generation
Distinguishing Features of Simulation Time (CLK)  DYNAMIC focused on this aspect during the modeling section of the course Pseudorandom variables (RND)
Simulation Input and Output Data Analysis
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
CSCE Monte Carlo Methods When you can’t do the math, simulate the process with random numbers Numerical integration to get areas/volumes Particle.
1 Simulation Modeling and Analysis Pseudo-Random Numbers.
1 Simulation Methodology H Plan: –Introduce basics of simulation modeling –Define terminology and methods used –Introduce simulation paradigms u Time-driven.
Discrete Event Simulation
1 Chapter 7 Generating and Processing Random Signals 第一組 電機四 B 蔡馭理 資工四 B 林宜鴻.
Random-Number Generation. 2 Properties of Random Numbers Random Number, R i, must be independently drawn from a uniform distribution with pdf: Two important.
Random Number Generation Fall 2013
Efficient Pseudo-Random Number Generation for Monte-Carlo Simulations Using GPU Siddhant Mohanty, Subho Shankar Banerjee, Dushyant Goyal, Ajit Mohanty.
Fall 2011 CSC 446/546 Part 6: Random Number Generation.
Random Number Generation Pseudo-random number Generating Discrete R.V. Generating Continuous R.V.
ETM 607 – Random Number and Random Variates
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.
Random-Number Generation Andy Wang CIS Computer Systems Performance Analysis.
1 Statistical Distribution Fitting Dr. Jason Merrick.

CS433 Modeling and Simulation Lecture 15 Random Number Generator Dr. Anis Koubâa 24 May 2009 Al-Imam Mohammad Ibn Saud Islamic University College Computer.
© 2003, Carla Ellis Simulation Techniques Overview Simulation environments emulation exec- driven sim trace- driven sim stochastic sim Workload parameters.
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.
Pseudo-random generators Random Number Generating There are three types of generators table look-up generators hardware generators algorithmic (software)
Monte Carlo Methods.
Experimental Method and Data Process: “Monte Carlo Method” Presentation # 1 Nafisa Tasneem CHEP,KNU
APPENDIX D R ANDOM N UMBER G ENERATION Organization of chapter in ISSO* – General description and linear congruential generators Criteria for “good” random.
Validating a Random Number Generator Based on: A Test of Randomness Based on the Consecutive Distance Between Random Number Pairs By: Matthew J. Duggan,
Testing Random-Number Generators Andy Wang CIS Computer Systems Performance Analysis.
Review of Probability. Important Topics 1 Random Variables and Probability Distributions 2 Expected Values, Mean, and Variance 3 Two Random Variables.
1/18/2016Atomic Scale Simulation1 Definition of Simulation What is a simulation? –It has an internal state “S” In classical mechanics, the state = positions.
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.
Parallel Random Number Generation
0 Simulation Modeling and Analysis: Input Analysis 7 Random Numbers Ref: Law & Kelton, Chapter 7.
MONTE CARLO METHOD DISCRETE SIMULATION RANDOM NUMBER GENERATION Chapter 3 : Random Number Generation.
6/11/2016Atomic Scale Simulation1 Definition of Simulation What is a simulation? –It has an internal state “S” In classical mechanics, the state = positions.
Random Numbers All stochastic simulations need to “generate” IID U(0,1) “random numbers” Other random variates coming from other distribution can be generated.
UNIFORM RANDOM NUMBER GENERATION Chapter 7 (first half) The goal is to generate a sequence of The goal is to generate a sequence of Uniformly distributed.
1.  How does the computer generate observations from various distributions specified after input analysis?  There are two main components to the generation.
3. Random Number Generator
Parallel Programming in C with MPI and OpenMP
Basic MC/Defn/Short Answer/Application Cumulative
CPSC 531: System Modeling and Simulation
Statistical Methods Carey Williamson Department of Computer Science
Random-Number Generation
Chapter 7 Random Number Generation
Chapter 7 Random-Number Generation
Properties of Random Numbers
Carey Williamson Department of Computer Science University of Calgary
Where real stuff starts
Presentation transcript:

1 Random Number Generation H Plan: –Introduce basics of RN generation –Define concepts and terminology –Introduce RNG methods u Linear Congruential Generator (LCG) u Explicit Inversive Congruential Generator u Non-linear Additive Feedback u Transform-Expand-Sample (TES) –Technical issues for RNGs u Testing RNGs

2 Motivation H Many simulations rely on use of random number generators (RNG) H Want to assess the “typical” behaviour of a system, and its average case perf H Single simulation run: one answer H Multiple runs: lots of (different) answers! H Central Limit Theorem: convergence to Normal distribution, with well-defined mean and variance (confidence intervals)

3 RNG Details H Truly random RNGs are hard to find H We settle for pseudo-random RNG H Assumes we can find “good” pseudo- random number generators H Assumes proper seeding of pseudo-RNG H Basic building block: U(0,1) H All other distributions can be generated from this using inverse mapping of CDF

4 Inverse Mapping (1 of 2) H If you have y = U(0,1), then you can generate x from any other distribution using inverse transformation (mapping) H Uses Cumulative Distribution Function (CDF) of the desired distribution H y = F(x) H x = F -1 (y) H Can be analytic formula or empirical data

5 Inverse Mapping (2 of 2) 0 x y 1 y = F(x) F(x) y1y1 y2y2 x1x1 x2x2

6 RNG Requirements H Uniformly distributed H Uncorrelated H Reproducible H Portable H Long Period H Analyzable H Computationally fast H Parallelizable H Scales suitably to any number of processors H Uncorrelated streams H Independent generation H Easy to use (API) H Gives right results!

7 LCG Basics H The most prevalent type of pRNG is the Linear Congruential Generator (LCG) H Formally a 4-tuple: LCG(m, a, b, y 0 ) with modulus m, multiplier a, offset b, and initial seed y 0 H Formula: y n+1 = (a y n + b) mod m H Generates pRN series in {0…m-1} H Can normalize to U(0,1) by dividing by m

8 LCG: Toy Example H Example: a=12, b=5, m=57, y 0 = 34 H Sequence: –34, 14, 2, 29, 11, 23, 53, 14, 2, 29, 11,... H Note the short cycle with period < m H In practice, want m large, and a, b, y 0 carefully chosen so that period is large H Some very good values are known

9 EICG H Another type is the Explicit Inversive Congruential Generator (EICG) H Also a 4-tuple: EICG(m, a, b, n 0 ) H Formula: y n = (an + b) mod m H Note the inversion modulo m

10 Some Typical RNGs H rand() 32-bit multiplicative CG H random() 32-bit non-linear additive FB H drand48() 48-bit LCG H erand48() 48-bit LCG H Some are better than others H Don’t forget to seed them properly!

11 RNG Testing H How to test the goodness of a RNG? H Large samples H Bucket analysis (uniformity test) H Auto-correlation analysis (second-order) H d-dimensional plots H Spectral tests H Discrepancy tests H Kolmogorov-Smirnov (KS) tests

12 RNG Issues H Size of stream used vs. generation period H General safety rule: square root H Want independent streams for each RV H How to generate for parallel/distributed –Splitting into non-overlapping blocks –Leap-frog technique p1p2p3p4 pipi pjpj

13 Transform-Expand-Sample (TES) H What if you want correlated RNs? H Use TES! H Map U(0,1) to unit circle (modulo 1) H Constrain location of subsequent points H Multiple constraints 01 0

14 Summary H Random number generation is at the heart of almost any computer simulation H Quality of the pRNG is very important (and often overlooked!) H Using RNG properly is important H Seeding them properly is important too H Statistical inference from simulation results only makes sense if RNG works