Docsity

Random Number Generation: Techniques, Tests, and Properties, Exams of Electrical and Electronics Engineering

Partial preview of the text

Download Random Number Generation: Techniques, Tests, and Properties and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

Chapter 7Random-NumberGeneration

Banks, Carson, Nelson & Nicol

Discrete-Event System Simulation

Purpose & Overview „

Discuss the generation of random numbers.

Introduce the subsequent testing forrandomness:

Frequency test

Autocorrelation test.

Generation of Pseudo-Random Numbers „

“Pseudo”, because generating numbers using a knownmethod removes the potential for true randomness.

„

Goal: To produce a sequence of numbers in [

0,

] that

simulates, or imitates, the ideal properties of random numbers(RN).

„

Important considerations in RN routines:

Fast

Portable to different computers

Have sufficiently long cycle

Replicable

Closely approximate the ideal statistical properties of uniformityand independence.

Techniques for Generating RandomNumbers „

Linear Congruential Method (LCM).

„

Combined Linear Congruential Generators (CLCG).

Example

[LCM]

„

Use

X

0

= 27

,

a = 17

,

c = 43

, and

m = 100

.

„

The

X

i

and

R

i

values are:

X

1

= (17*27+43) mod 100 = 2,

R

1

X

2

= (17*2+32) mod 100 = 77,

R

2

X

3

= (17*77+32) mod 100 = 52,

R

3

Characteristics of a Good Generator

[LCM]

„

Maximum Density

Such that he values assumed by

R

, i = 1,2,…i

, leave no large

gaps on

[0,1]

Problem: Instead of continuous, each

R

i^

is discrete

Solution: a very large integer for modulus m

„

Approximation appears to be of little consequence

„

Maximum Period

To achieve maximum density and avoid cycling.

Achieve by: proper choice of

a

c

m

, and

X

0

„

Most digital computers use a binary representation ofnumbers

Speed and efficiency are aided by a modulus,

m

, to be (or close

to) a power of

Combined Linear Congruential GeneratorsTheorem: If

are any independent discrete-

valued random variable, and

is uniformly

distributed on

then

W

i ,

W

i ,

W

i , k

W

i ,

[0,

m

1

−

2]

W

i

W

i ,^

j

j^

=

1 k ∑

mod(

m

1

is uniformly distributed on

[0,

m

1

2]

11

Combined Linear Congruential Generators

[Techniques]

Suggested form:

„

The maximum possible period is:

X

i

=

W

i ,

(

−

j −

1

X

i ,^

j

j

2 k ∑

⎛ ⎜⎜⎝

⎞ ⎟⎟⎠

mod (

m

1

−

Hence,

R

i^

X

i

m

1

X

i

m

1

m

1

X

i

1

2

1

−

k

k

m

m

m

P

The coefficient:

Performs the subtraction

X

i,1-

Tests for Random Numbers „

Two categories:

Testing for uniformity:

H

0

R

i^

~ U[0,1]
H

1

R

i^

~ U[0,1]

„

Failure to reject the null hypothesis, H

0

, means that evidence of

non-uniformity has not been detected.

Testing for independence:

H

0

R

i^

~ independently

H

1

R

i^

~ independently

„

Failure to reject the null hypothesis, H

0

, means that evidence of

dependence has not been detected.

„

Level of significance

α,

the probability of rejecting H

0

when it

is true:

α

= P(reject H

0

|H

0

is true)

/ /

Tests for Random Numbers „

When to use these tests:

If a well-known simulation languages or random-numbergenerators is used, it is probably unnecessary to test

If the generator is not explicitly known or documented, e.g.,spreadsheet programs, symbolic/numerical calculators, testsshould be applied to many sample numbers.

„

Types of tests:

Theoretical tests: evaluate the choices of m, a, and c withoutactually generating any numbers

Empirical tests: applied to actual sequences of numbersproduced. Our emphasis.

Kolmogorov-Smirnov Test

[

Frequency Test]

„

Compares the continuous cdf,

F(x)

, of the uniform

distribution with the empirical cdf,

S

N

(x),

of the

N

sample

observations.

We know:

If the sample from the RN generator is

R

1

, R

2

, …, R

N

, then the

empirical cdf,

S

N

(x)

is:

„

Based on the statistic:

D = max| F(x) - S

N

(x)|

Sampling distribution of

D

is known

(a function of

N

, tabulated in

Table A.8.)

„

A more powerful test, recommended.

1

0

,

)

(

≤

≤

=

x

x

x

F

N

x R R R x S

n

N

≤

=

are

which

,...,

,

of

number

)

(

2

1

17

Kolmogorov-Smirnov Test

[

Frequency Test]

„

Example: Suppose

5

generated numbers are

0.44, 0.81, 0.14,

0.05, 0.

.

Step 1: Step 2: Step 3:

D = max(D

+

, D

- ) = 0.

Step 4:

For

α

= 0.

,

D

α

= 0.565 > D

Hence,

H

0

is not rejected.

Arrange R

(i)

from

smallest to largest D

+

= max {i/N – R

(i)

}

D

-^

= max {R

(i)

- (i-1)/N}

R

(i)

- (i-1)/N

i/N – R

(i)

i/N

R

(i)

Tests for Autocorrelation

[Tests for RN]

„

Testing the autocorrelation between every m numbers(m is a.k.a. the lag)

The autocorrelation

m

between numbers:

R

, Ri

i+m

, R

i+2m

R

i+(M+1)m

M

is the largest integer such that

„

Hypothesis:

„

If the values are uncorrelated:

For large values of M, the distribution of the estimator of

m

denoted

is approximately normal.

N

)m

(M

i

≤

1

ρ

m

H

0

:

ρ

m

=

0,

if numbers are independent

H

1

:

ρ

m

≠

0,

if numbers are dependent

Tests for Autocorrelation

[Tests for RN]

„

Test statistics is:

Z

0

is distributed normally with mean =

0

and variance =

1

„

If

m

> 0, the subsequence has positive autocorrelation

High random numbers tend to be followed by high ones, and vice versa.

„

If

m

< 0, the subsequence has negative autocorrelation

Low random numbers tend to be followed by high ones, and vice versa.

Z

0

=

ˆ ρ

m

ˆ σ

ˆ ρ

m