0% found this document useful (0 votes)
63 views24 pages

Simkom-Materi Week 5 - Random-Number & Random-Variate Generation

Uploaded by

Anisa Shyafitry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views24 pages

Simkom-Materi Week 5 - Random-Number & Random-Variate Generation

Uploaded by

Anisa Shyafitry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

1

IEH3Q2 – Simulasi Komputer

Statistical Models in Simulation:


Review
Jurusan Teknik Industri
Fakultas Rekayasa Industri
Ganjil 19/20

Acuan:
v Harrell, C. , “Simulation Using ProModel, 2nd Edition”, The McGraw-Hill, 2004.
Content Overview 3

Statistical Models in Simulation: Review

Generating Random
Generating Random Variates
Numbers

3
4

Simulating Random Behavior

• One of the most powerful features of


simulation is its ability to mimic random
behavior or variation that is characteristic of
stochastic systems.
• Simulating random behavior requires that a
method be provided to generate random
numbers as well as for generating random
variates based on a given probability
distribution.
Generating Random
5

Behavior
Random behavior is imitated in simulation by
using a random number generator.
Random number generator is responsible for
producing this stream of independent and
uniformly distributed numbers.
The heart of the simulation is the generation of
the random variates that drive the
stochastic events in the simulation
6

Generating Random Behavior


The U(0, 1) distribution of a random number
generator
7

Generating Random Behavior


The numbers produced by a random number generator
are not “random” in the truest sense.
- The generator can produce the same sequence of
numbers again and again, which is not indicative of
random behavior.
- They are often referred to as pseudo-random number
generators.
“Good” pseudo-random number generators can pump
out long sequences of numbers that pass statistical
tests for randomness (the numbers are independent
and uniformly distributed).
8

Generating Random Behavior


• The most common method for generating random
numbers is Linear Congruential Generators (LCG).
• Using LCG, a sequence of integers Z1, Z2, Z3, ... is
defined by the recursive formula:

Z i = (aZ i -1 + c ) mod(m )
a : the multiplier;
c : the increment;
m : the modulus;
Z0 : the seed or starting value;
a, c, m > 0 and integer
9
Linear Congruential Generators (LCG)

• The Zi values are bounded by 0 £ Zi £ m – 1 and are


uniformly distributed in the discrete case.
• The continuous version of the uniform distribution
with values ranging between 0 and 1 can be
obtained by

Zi
U i = , i = 1,2,3, !
m
10
Linear Congruential Generators (LCG)
i Zi Ui
Example of LCG
0 13
1 4 0.2500
2 7 0.4375
a = 21 3
4
6
1
0.3750
0.0625

c=3 5
6
8
11
0.5000
0.6875

m = 16
7 10 0.6250
8 5 0.3125
9 12 0.7500
10 15 0.9375
11 14 0.8750
12 9 0.5625
13 0 0.0000
14 3 0.1875
15 2 0.1250
16 13 0.8125
17 4 0.2500
18 7 0.4375
19 6 0.3750
20 1 0.0625
11
Linear Congruential Generators (LCG)

1. The maximum cycle length that an LCG can achieve is


m.
2. To realize maximum cycle length, the values of a, c,
and m have to be carefully selected.
3. A guideline for the selection is:
§m = 2b where b is determined based on the number of bits
per word on the computer being used (for computer with 32
bits, b = 31)
§c and m such that their greatest common factor is 1.
§a = 1 + 4k, where k is an integer.
12

Linear Congruential Generators (LCG)

The LCG has full period if and only if the following three
conditions hold (Hull and Dobell, 1962):
1. The only positive integer that (exactly) divides both
m and c is 1
2. If q is a prime number (divisible by only itself and 1)
that divides m, then q divides a–1
3. If 4 divides m, then 4 divides a–1
13

Linear Congruential Generators (LCG)


Frequently, the long sequence of random number is
subdivided into smaller segments referred to as
streams.
To subdivide the generator’s sequence of random
numbers into streams, we need:
§to decide how many random numbers to place in each
stream
§to generate the entire sequence of random numbers
(cycle length) produced by the generator and record the Zi
values that mark the beginning of each stream.
Each stream has its own starting or seed value.
15

Testing Random Number Generators

The numbers produced by the random number


generator must satisfy two properties:
§ Independent (runs test)
§ Uniformly distributed between zero and one
(Kolmogorov-Smirnov and chi-square)
16

Testing Random Number Generators


The hypothesis for testing the uniformly property:
H0 : Ui values are U(0, 1)
H1 : Ui values are not U(0, 1)
The most common statistical methods:
§ The Kolmogorov-Smirnov test
§ The chi-square test
17

Generating Random Variates


Methods for generating random variates from a desired
distribution:
§ Inverse transformation
§ Composition
§ Convolution
§ Acceptance-Rejection
§ Methods employing special properties
The most common method is the inverse
transformation
19

Inverse Transformation Method


Generating variates from the exponential
distribution with mean b.
The probability density function f(x):
ì 1 -x / b
ï e , x>0
f (x ) = í b
ïî0, elsewhere

The cumulative distribution function F(x):


ì1 - e - x / b , x > 0
F (x ) = í
î0, elsewhere
20

Inverse Transformation Method


Setting U = F(x) and solving for x yields:

U = 1 - e- x / b
e- x / b = 1 - U
( )
ln e - x / b = ln (1 - U )
- x b = ln (1 - U )
x = - b ln (1 - U )
The random variate x is exponentially
distributed with mean b.
21

Inverse Transformation Method


b =2 U1 = 0.27 ® x1 = -2 ln (1 - 0.27 ) = 0.63
U1= 0.27 U 2 = 0.89 ® x2 = -2 ln (1 - 0.89 ) = 4.41
U2=0.89
22

Inverse Transformation Method


Discrete distribution
§For a given probability mass function p(x), find the
cumulative distribution function of X, i.e., F(x) = P(X £
x).
§It is assumed that X take on only the values x1, x2, ...
where x1 < x2 < ... .
§Algorithm:
-Generate U ~ U(0, 1)
-Determine the smallest positive integer I such that U £
F(xi), and return X = Xi.
24

Inverse Transformation Method


Generating variates from the following probability
mass function (arbitrary discrete distribution):

ì0.10, x = 1
ï
p( x ) = P( X = x ) = í0.30, x = 2
ï0.60, x = 3
î
25

Inverse Transformation Method


The cumulative distribution function F(x)

U1 = 0.27, because 0.10 < U1 £ 0.40 then x1 = 2


26

Generating variates
from other distributions:
Techniques and algorithms for generating variates from
other distributions:
§continuous: uniform, exponential, m-Erlang, Gamma,
Weibull, normal, lognormal, beta, Pearson type V, Pearson
type VI, triangular, empirical distribution,
§discrete: Bernoulli, discrete uniform, arbitrary discrete
distribution, binomial, geometric, negative binomial,
Poisson
see Law and Kelton, Simulation Modeling and
Analysis, Chapter 8.
27

Activity

Kasus Sistem ATM

a 21
m 128
c 3
betha-1 3 Arrival to ATM
betha-2 2.4 ATM Processing Time

Z0-1 3 Arrival to ATM


Z0-2 122 ATM Processing Time

Buatlah Random number dan Variatenya!

27
28

28

You might also like