Techniques in Signal Processing CSC 508 Generating Random Numbers with a Computer.

Slides:



Advertisements
Similar presentations
Python Crash Course Accuracy 3 rd year Bachelors V1.0 dd Hour 7.
Advertisements

Generating Random Numbers
Copyright © Cengage Learning. All rights reserved.
Random number generation Algorithms and Transforms to Univariate Distributions.
KS3 Mathematics N4 Powers and roots
Central Limit Theorem.
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
Continuous Random Variables & The Normal Probability Distribution
Simulation Modeling and Analysis
Pseudorandom Number Generators
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
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.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
1 Simulation Modeling and Analysis Pseudo-Random Numbers.
Properties of Random Numbers
1 Chapter 7 Generating and Processing Random Signals 第一組 電機四 B 蔡馭理 資工四 B 林宜鴻.
Lecture (16) Introduction to Stochastic Hydrology.
ETM 607 – Random Number and Random Variates
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Elementary Algebra Exam 1 Material.
Skills for October Rounds
Mathematics of Cryptography Part I: Modular Arithmetic
MATH 224 – Discrete Mathematics
2.1 Integers Natural (Counting) Numbers: 1, 2, 3, 4, …
The University of Texas at Arlington Topics in Random Processes CSE 5301 – Data Modeling Guest Lecture: Dr. Gergely Záruba.
Dept of Bioenvironmental Systems Engineering National Taiwan University Lab for Remote Sensing Hydrology and Spatial Modeling STATISTICS Random Variables.
Chapter 6 Probability. Introduction We usually start a study asking questions about the population. But we conduct the research using a sample. The role.
Section 8.1 Estimating  When  is Known In this section, we develop techniques for estimating the population mean μ using sample data. We assume that.
Random-Number Generation Andy Wang CIS Computer Systems Performance Analysis.
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.
Chapter 7 Random-Number Generation
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.
1 Lesson 8: Basic Monte Carlo integration We begin the 2 nd phase of our course: Study of general mathematics of MC We begin the 2 nd phase of our course:
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.
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.
Linear Feedback Shift Register. 2 Linear Feedback Shift Registers (LFSRs) These are n-bit counters exhibiting pseudo-random behavior. Built from simple.
Lecture 5 Methods. Sometimes we want to perform the same sequence of operations multiple times in a program. While loops allow us to do this, they are.
COMP155 Computer Simulation September 8, States and Events  A state is a condition of a system at some point in time  An event is something that.
Monte Carlo Process Risk Analysis for Water Resources Planning and Management Institute for Water Resources 2008.
Chapter 10 Hashing. The search time of each algorithm depend on the number n of elements of the collection S of the data. A searching technique called.
Decidable languages Section 4.1 CSC 4170 Theory of Computation.
This is an example of an infinite series. 1 1 Start with a square one unit by one unit: This series converges (approaches a limiting value.) Many series.
CHAPTER 5 Simulation Modeling. Introduction In many situations a modeler is unable to construct an analytic (symbolic) model adequately explaining the.
Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering National Taiwan University 1/45 GEOSTATISTICS INTRODUCTION.
R ANDOM N UMBER G ENERATORS Modeling and Simulation CS
Sec 6.3 Bluman, Chapter Review: Find the z values; the graph is symmetrical. Bluman, Chapter 63.
Lecture 6: Floating Point Number Representation Information Representation: Floating Point Number Representation Lecture # 7.
REAL NUMBERS (as opposed to fake numbers?) Why do we have to review numbers Miss Price? Be a beast in Math when you know the basics!
0 Simulation Modeling and Analysis: Input Analysis 7 Random Numbers Ref: Law & Kelton, Chapter 7.
Module 9.2 Simulations. Computer simulation Having computer program imitate reality, in order to study situations and make decisions Applications?
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.
MATH BASICS Learning the Terminology. Look at the following problem: How many even prime numbers are there between 0 and 100. A. 0 B. 1 C. 2 D. 3 E. 4.
Section 7.6 Functions Math in Our World. Learning Objectives  Identify functions.  Write functions in function notation.  Evaluate functions.  Find.
Square Roots. Perfect Squares Squaring is when a number is multiplied by itself – It’s called squared because the area of a square is multiplying a side.
Unit 1 MM 150: Number Theory and the Real Number System Prof. Carolyn Dupee July 3, 2012.
Algebra 2 Properties of Real Numbers Lesson 1-2 Goals Goal To graph and order real numbers. To Identity properties of real numbers. Rubric Level 1 –
Introductory Algebra Glossary The Language of Math.
Lesson 8: Basic Monte Carlo integration
Sampling rate conversion by a rational factor
Sampling Distributions and The Central Limit Theorem
Random-Number Generation
Quantitative Reasoning
Random Number Generation
Sampling Distributions and The Central Limit Theorem
Presentation transcript:

Techniques in Signal Processing CSC 508 Generating Random Numbers with a Computer

2.3 Generating Random Numbers Before we begin this section, it is important to realize that a digital (VonNeumann architecture) computer cannot generate sequences of random numbers. Only after you accept and understand this will we proceed to generate sequences of random numbers with a computer. At this point some explanation is in order: A conventional digital computer is perfectly deterministic and, therefore, is incapable of exhibiting any sort of random behavior (unless it is broken). Computation methods exist t generate sequences of numbers that appear to be random and that pass certain standard tests for randomness. These are called pseudo-random sequences. You must appreciate this difference to avoid embarassing and sometimes costly errors and simulation and analysis. Any simulation or other computer-based analysis which relies on the randomness of a pseudo-random sequence, is susceptable to a special kind of error. Improperly used, a pseudo-random sequence can produce structure or artifacts in your data that are a product of the pseudo-random number generator itself rather than a real feature of the system being modeled. The most important thing to remember is that every pseudo-random number sequence generated on a computer will eventually begin to repeat itself. We must never draw from such a sequence past this point.

Method of Congruence One of the most popular methods of generating pseudo-random sequences is called the method of congruence. A sequence of n pseudo-random number X n ={x 0,x 1,..., x n ) may be generated by the recurrence relation, where we establish the following relationship between the values a,b and T: (1) T is the maximum possible value in Xn, (a function of our computer). (2) b is relatively prime to T (i.e. they have no common factors) (3) a = 1 mod p where p is a prime factor of T. (4) a = 1 mod 4 if 4 is a factor of T. For example, if we let T=2q then b must be odd and we must ensure that a=1 mod 4. If we let T=10q then b cannot be divisible by 2 or 5 (the prime factors of T) and we must choose a value of a so that a = 1 mod 20. To answer the question building in your mind. No. We cannot rely on the built-in random number generators provided with most lanuage compilers. These ready-to-go random number generators are notoriously flawed and inadequate for serious computer research.

A simple Ada function using the method of congruence is shown below. This function generates a uniformly distributed pseudo-random sequence. An inital seed value for XVAL (say 141) is needed to start the sequence. Each time RAN(MAXVAL) is called an integer between 0 and MAXVAL is returned. If our computer can represent integers up to in value then we must make sure that A*XVAL+B does not exceed this value. As a test we note that for XVAL 0 =141, T=2 10, A=2 4 +1=17 and B=1 The maximum value of XVAL is T-1 or 1023 and that A*XVAL+B never exceeds which is <

In general the value of MAXVAL must not be set larger than T/2, otherwise some values in the range (0..MAXVAL) cannot be generated by RAN. This is due to the truncation in the conversion from floating point back to integer type in the RAN function. Now that we have established the maximum size for MAXVAL, we should consider how many values can be drawn from RAN before we are in danger of obtaining a repeated sequence. A good rule of thumb is to never exceed the square root of the maximum number of values which can be represented by the computer system we are using. In our case we are limited to /2 =181. Those of you with programming experience may be interested in testing the random number generator built into your favorite programming language for the length of repeating sequences. (Or maybe not.) We can use a uniform random number generator to generate random numbers over any range of values. For example, we can use RAN to produce a source of random floating- point numbers U [ ] in the range [-1.0,+1.0] with the following scaling transormation, where MAXVAL is the largest integer allowed as an upper limit for the function RAN. In general, a uniform random distribution over any range can be obtained through a process of scaling and shifting the values produced by RAN.

Consider the graph on the left in which a random deviate x in the range [0,MaxVal] is used in the transform- ation function R(x) to compute a new uniform deviate in the range [-1.0,+1.0]. This is called the inverse method of generating random deviates and can be used to generate other types of random distributions such as the normal distribution from a uniform distribution. To use the inverse method to produce normally distributed random numbers we need to find a function N(x) to replace R(x). This function must map uniformly distributed values U(x) into normally distributed values N(x).

N(x) is the functional inverse of the integral of the Gaussian PDF. This integral is called the cumlative distribution function (CDF) and has no closed-form solution. We can approximate N(x) using a method after Abramowitz and Stegun, as shown in this chart. This approximation produces values of N(x) which are good to within +/ _ 4.5x10 -4 when modeling a normal distribution with zero mean and unit sigma. You can then convert these normal deviates to any mean and standard deviation by multiplying each times the desired  and adding the desired . N'(x) =  N(x) + 

The Direct Method of Generating Normal Deviates Another method for generating normal deviates is called the direct method. Given two draws from a uniform random distribution U 1 and U 2 with range [0.0,1.0], we generate two independent normal random deviates N 1 and N 2 by, Remember that the implied mean of the normal distribution is 0.0 and the standard deviation is 1.0 for the normal distribution modeled using the direct method. What values of U 1 and U 2 produce the largest positive and largest negative values for N? What values of U 1 and U 2 result in N=0.0? This is the preferred method when the cost of computing the logarthims and trigonometric functions is not prohibitive. With the nearly universal availability of CPUs with built-in math coprocessors, the direct method of computing normal random deviates is becoming the standard.