Presentation is loading. Please wait.

Presentation is loading. Please wait.

Properties of Random Numbers

Similar presentations


Presentation on theme: "Properties of Random Numbers"— Presentation transcript:

1 Properties of Random Numbers
Lecture 5 Properties of Random Numbers

2 Random Number Generation
A simulation of any system or process in which there are inherently random components requires a method of generating or obtaining numbers that are random, in some sense. The earliest methods were carried out by hands such as throwing dice. As computers (and simulation) became more widely used, increasing attention was paid to methods of random number generation compatible with the computers work.

3 Random Number Generation (cont’)
Therefore, the research in the 1940’s and 1950’s turned to numerical or arithmetic ways to generate “random” numbers. These method are sequential, with each new number being determined by one or several of its predecessors according to a fixed mathematical formula. The first such arithmetic generate generator, proposed by von Neumann and Metropolic in the 1940’s is the famous midsquare method.

4 Midsquare Method An example of midsquare method for generating a uniform [0, 1] random numbers: i Zi Ui Zi2 7182 - 1 5811 0.5811 2 7677 0.7677 3 9363 0.9363 4 6657 0.6657 5 3156 0.3156 .

5 Midsquare Method (cont’)
Drawbacks for midsquare method If Zi = 0 for some i, then Uj = Zj = 0 for all j > i. Ui+1 is determined by Ui, i.e. Ui+1 is a function of Ui. Therefore, Ui and Ui+1 are not independent. Nowadays, the random numbers generated from computers are more complicated and appear to be independent, in that they pass a series of statistical test. But after all, the random numbers generated from computers are still not purely random (pseudorandom, but too awkward to use this term).

6 Good Random Number Generation
A “good” arithmetic random number generator should posses several properties: Above all, the numbers produced should appear to be distributed uniformly on [0, 1] and should not exhibit any correlation with each other; otherwise, the simulation’s results may be completely invalid. From a practical standpoint, we would naturally like the generator to be fast and avoid the need for a lot of storage. We would like to be able to reproduce a given stream of random numbers exactly, for at least two reasons. First, this can sometimes make debugging or verification f the computer program easier. More important, we might want to use identical random numbers in simulating different systems in order to obtain a more precise comparison.

7 Good Random Number Generation (cont’)
There should be provision in the generator for producing several separate “stream” of random numbers. As we shall see, a stream is simply a subsegment of the numbers produced by the generator, with one stream beginning where the previous stream ends.

8 Methods for Generation
Inverse Transform Technique (ITT) Exponential distribution Uniform distribution Triangular distribution Empirical discrete distribution Empirical continuous distribution Acceptance-Rejection Technique

9 Inverse Transform Technique
The inverse transform technique can be used to sample from the exponential, the Weibull and the uniform distributions, and empirical distribution. Additionally, it is the underlying principle for sampling from a wide variety of discrete distributions. A step by step procedure for the inverse transform techniques, illustrated by the exponential distribution, is as follows: Step 1 Compute the cdf of the desired random variable. For the exponential distribution, the cdf is

10 Inverse Transform Technique (cont’)
Step 2 Set F(x) = R on the range of X. For the exponential distribution, it becomes on the range Since X is a random variable (with the exponential distribution in this case), it follows that is also a random variable, here called R. As will be shown later, R has a uniform distribution over the interval (0, 1).

11 Inverse Transform Technique (cont’)
Step 3 Solve the equation F(X) = R for X in terms of R. For the exponential distribution, the solution proceeds as follows:

12 Inverse Transform Technique (cont’)
Step 4 Generate (as needed) uniform random number R1, R2, R3,…, and compute the desired random variable by where One simplification that is usually employed is to replace by to yield which is justified since both and are uniformly distributed on (0, 1).

13 Uniform Distribution Consider a random variable X that is uniformly distributed on the interval [a, b]. The pdf of X is given by Step 1 The cdf is given by Step 2 Set F(X) = (X – a) / (b – a) = R Step 3 Solving for X in terms of R yields X = a + (b – a) R b a

14 Triangular Distribution
Consider a random variable X which has pdf This distribution is called a triangular distribution with endpoints (0, 2) and mode at 1. Step 1 The cdf is given by f(x) 1 1 2

15 Empirical Discrete Distributions
Service Time Probability Cumulative Probability Random Number 1 0.10 0.01 – 0.10 2 0.20 0.30 0.11 – 0.30 3 0.60 0.31 – 0.60 4 0.25 0.85 0.61 – 0.85 5 0.95 6 0.05 1.00 0.96 – 000 1 p(x) 1 2 3 4 0.3 0.2 0.1 5 6 1 Draw a sample from a 0-1 uniform distribution Convert the 0-1 sample to an equivalent sample from the target population 2

16 Empirical Continuous Distribution
If the modeler has been unable to find a theoretical distribution that provides a good model for the input data, then it may be necessary to use the empirical distribution of the data. Suppose that 100 broken-widget repair times have been collected. The data are summarized in the following table in terms of the number of observations in various interval. For example, there were 31 observations between 0 and 0.5 hour, 10 between 0.5 and 1 hour, and so on. Interval (Hours) Frequency Relative Frequency Cumulative Frequency 0.0  x  0.5 31 0.31 0.5 < x  1.0 10 0.10 0.41 1.0 < x  1.5 25 0.25 0.66 1.5 < x  2.0 24 0.24 1.00

17 Empirical Continuous Distribution (cont’)
(1.5, 0.66) (2.0, 1.0) (1.0, 0.41) (0.5, 0.31) 0.5 1.0 1.5 2.0 X1=1.75 0.8 0.6 0.4 0.2 R1=0.83 F(x) x Repair times Cumulative probability

18 Acceptance-Rejection Technique
Suppose that we need to devise a method for generating random variates, X, uniformly distributed between ¼ and 1. Step 1: Generate a random number u ~ U (0, 1) Step 2a: If , accept X = u, then go to step 3. Step 2b: If , reject u, and return to step 1. Step 3: If another uniform random variate on [1/4, 1] is needed, repeat the procedure beginning at step 1. If not, stop.

19 Tests for Random Numbers
The desirable properties of random numbers uniformity and independence To insure that these desirable properties are achieved, a number of tests can be performed. The tests can be placed in two categories according to the properties of interest. Test for uniformity Test for independence

20 Tests for Random Numbers (cont’)
Frequency test: Uses the chi-square test to compare the distribution of the set of numbers generated to a uniform distribution. Runs test: Tests the runs up and down or the runs above and below the mean by comparing the actual values to expected values. The statistic for comparison is the chi-square.

21 Frequency Test FREQUENCY TEST
Random numbers about from the uniform distribution and several tests have been developed to test for this condition. We will consider the 2 goodness-of-fit test. The goodness-of-fit test requires that: 50 observations in total Expected frequency of at least five in each class The following table shows the results of placing a total of 100 observations in 10 evenly spaced classes

22 Frequency Test (cont’)
Classes Observed Frequency Expected Frequency (fo – fe)2 / fe 0.00 – 0.10 9 10 0.10 0.10 – 0.20 12 0.40 0.20 – 0.30 0.00 0.30 – 0.40 11 0.40 – 0.50 8 0.50 – 0.60 0.60 – 0.70 0.70 – 0.80 7 0.90 0.80 – 0.90 0.90 – 1.00 100 2.40

23 Frequency Test (cont’)
The question is, Do these numbers come from the uniform distribution? Calculating the 2 statistic from the data using the equation Gives a value of 2 = In testing the null hypothesis that the random numbers come from the uniform distribution, H0 : Ri ~ U [0, 1] one compares the calculated 2 to the value obtained from the table based on (10-1) = 9 degree of freedom and a  = 0.05. This 2 value is found to be , which is larger than the calculated 2 value. Therefore, we accepted the null hypothesis, and find our random number generation acceptable.

24 Run Up and Down Test RUNS UP AND DOWN TEST
Numbers can pass a uniformity test and still not be random. For example, the numbers 0.00, 0.10, 0.20, 0.30, 0.40, …obviously are not random. The numbers also must be sequentially random to be judged truly random. A variety of runs test can be used for this purpose. We will consider a run up and down test.

25 Run Up and Down Test (cont’)
In a sequence of numbers, if a number is followed by a larger number, this is an upward run. Likewise, a number followed by a smaller number is a downstream run. If the numbers are truly random, one would expect to find a certain numbers of runs up and down. In a sequence of N numbers, one should expect to find runs equal to the following equation:

26 Run Up and Down Test (cont’)
As an example, assume that the following 40 numbers have been generated. 0.43, 0.32, 0.48, 0.23, 0.90, 0.72, 0.94, 0.11, 0.14, 0.67, 0.61, 0.25, 0.45, 0.56, 0.87, 0.54, 0.01, 0.64, 0.65, 0.32, 0.03, 0.93, 0.08, 0.58, 0.41, 0.32, 0.03, 0.18, 0.90, 0.74, 0.32, 0.75, 0.42, 0.71, 0.66, 0.03, 0.44, 0.99, 0.40, 0.51 + + + + + + + + + + + + +

27 Run Up and Down Test (cont’)
One should expect to find runs There were 26 runs in the sequence of numbers. We consider to accept the generated numbers are random.

28 Table of Random Digits 10097 32533 76520 13586 34673 54876 80959 09117 39292 74945 37542 04805 64894 74296 24805 24037 20636 10402 00822 91655 08422 68953 19645 09303 23209 02560 15953 34764 35080 33606 99019 02529 09376 70715 38311 31165 88676 74397 04436 27659 12807 99970 80157 36147 64032 36653 98951 16877 12171 76833 66065 74717 34072 76850 36697 36170 65813 39885 11190 29170 31060 10805 45571 82406 35303 42614 86799 07439 23403 09732 85269 77602 02051 65692 68665 74818 73053 85247 18623 88579 63573 32135 05325 47048 90553 57548 28468 28709 83491 25624 73796 45753 03529 64778 35808 34282 60935 20344 35273 88435 98520 17767 14905 68607 22109 40558 60970 93433 50500 73998 11805 05431 39808 27732 50725 68248 29405 24201 52775 67851


Download ppt "Properties of Random Numbers"

Similar presentations


Ads by Google