Simulation Simulation Modeling and Performance Analysis with - - PowerPoint PPT Presentation

simulation simulation
SMART_READER_LITE
LIVE PREVIEW

Simulation Simulation Modeling and Performance Analysis with - - PowerPoint PPT Presentation

Computer Science, Informatik 4 Communication and Distributed Systems Simulation Simulation Modeling and Performance Analysis with Discrete-Event Simulation g y Dr. Mesut Gne Computer Science, Informatik 4 Communication and Distributed


slide-1
SLIDE 1

Computer Science, Informatik 4 Communication and Distributed Systems

Simulation Simulation

Modeling and Performance Analysis with Discrete-Event Simulation g y

  • Dr. Mesut Güneş
slide-2
SLIDE 2

Computer Science, Informatik 4 Communication and Distributed Systems

Chapter 7

Random-Variate Generation

slide-3
SLIDE 3

Computer Science, Informatik 4 Communication and Distributed Systems

Contents Contents Inverse-transform Technique Inverse transform Technique Acceptance-Rejection Technique Special Properties p p

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 3

slide-4
SLIDE 4

Computer Science, Informatik 4 Communication and Distributed Systems

Purpose & Overview Purpose & Overview Develop understanding of generating samples from a Develop understanding of generating samples from a specified distribution as input to a simulation model. Illustrate some widely-used techniques for generating random variates.

I t f t h i

  • Inverse-transform technique
  • Acceptance-rejection technique
  • Special properties

Special properties

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 4

slide-5
SLIDE 5

Computer Science, Informatik 4 Communication and Distributed Systems

Preparation Preparation It is assumed that a source of uniform [0,1] random numbers It is assumed that a source of uniform [0,1] random numbers exists.

  • Linear Congruential Method (LCM)

Random numbers R, R1, R2, … with

PDF

  • PDF

⎩ ⎨ ⎧ ≤ ≤ = th i 1 1 ) ( x x fR

  • CDF

⎩ ⎨

  • therwise

) ( fR

⎪ ⎪ ⎨ ⎧ ≤ ≤ < = 1 ) ( x x x x FR

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 5

⎪ ⎩ >1 1 x

slide-6
SLIDE 6

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique Inverse transform Technique

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 6

slide-7
SLIDE 7

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique Inverse-transform Technique The concept: The concept:

  • For CDF function: r = F(x)
  • Generate r from uniform (0,1), a.k.a U(0,1)
  • Find x,

x = F-1(r)

F(x) 1 F(x) 1 r1

r = F(x)

1 r1

r = F(x)

1

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 7

x1 x x1 x

slide-8
SLIDE 8

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique Inverse-transform Technique

  • The inverse-transform technique can be used in principle for

The inverse transform technique can be used in principle for any distribution.

  • Most useful when the CDF F(x) has an inverse F -1(x) which

is easy to compute. R i d t

  • Required steps
  • 1. Compute the CDF of the desired random variable X.

2 Set F(X) = R on the range of X

  • 2. Set F(X) R on the range of X.
  • 3. Solve the equation F(X) = R for X in terms of R.
  • 4. Generate uniform random numbers R1, R2, R3, … and compute

the desired random variate by Xi = F-1(Ri)

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 8

slide-9
SLIDE 9

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Example Inverse-transform Technique – Example

  • Exponential Distribution
  • To generate X1, X2, X3 …

p

  • PDF

g

1, 2, 3

x

e x f

λ

λ

= ) (

1 R e

X −

= −

λ

  • CDF

x

e x F

λ −

− =1 ) (

) 1 ln( 1 R X R e

X −

− = − − = λ

λ

e x F =1 ) (

) 1 ln( ) 1 ln( R X R X − = λ λ ) 1 ln( R X − − = − λ λ

  • Simplification

) ln(R

) (

1 R

F X

= λ

  • Since R and (1 R) are

λ ) ln(R X − =

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 9

  • Since R and (1-R) are

uniformly distributed on [0,1]

slide-10
SLIDE 10

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Example Inverse-transform Technique – Example

Inverse-transform technique for exp(λ = 1)

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 10

q p( )

slide-11
SLIDE 11

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Example

  • Example: Generate 200 variates Xi with distribution exp(λ= 1)

Inverse-transform Technique – Example

Example: Generate 200 variates Xi with distribution exp(λ 1)

  • Generate 200 Rs with U(0,1), the histogram of Xs becomes:

0,6 0,7 0 3 0,4 0,5 0,1 0,2 0,3 0,1 0,5 1 1,5 2 2,5 3 3,5 4 4,5 5 5,5 6 6,5 7 Empirical Histogram Theor PDF

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 11

Empirical Histogram

  • Theor. PDF
slide-12
SLIDE 12

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique Inverse-transform Technique

  • Check: Does the random variable X1 have the desired distribution?

1

) ( )) ( ( ) (

1 1

x F x F R P x X P = ≤ = ≤

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 12

slide-13
SLIDE 13

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Other Distributions Inverse-transform Technique – Other Distributions Examples of other distributions for which inverse CDF works Examples of other distributions for which inverse CDF works are:

  • Uniform distribution
  • Weibull distribution
  • Triangular distribution
  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 13

slide-14
SLIDE 14

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Uniform Distribution Inverse-transform Technique – Uniform Distribution Random variable X uniformly distributed over [a, b] Random variable X uniformly distributed over [a, b]

) ( R X F = ) ( R b a X R X F = − ) ( a b R a X a b − = − − ) ( a b R a X − + =

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 14

slide-15
SLIDE 15

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Weibull Distribution Inverse-transform Technique – Weibull Distribution

  • The Weibull Distribution is
  • The variate is

described by

PDF

( )

β

) ( R X F

X

=

  • PDF

( ) ( )

β α α

1 1 R e R e

X X

− = = −

− −

( )

β α

β β

α β

x

e x x f

− −

=

1

) (

  • CDF

( )

β β α

) 1 ln( X R

X

− = −

α

  • CDF

( )

β α x

e X F

− =1 ) (

β β β β

α α ) 1 ln( ) 1 ln( R X R X − − =

β β β β

α α ) 1 ln( ) 1 ln( R x R X − ⋅ − = − ⋅ − =

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 15

β

α ) 1 ln( R X − − ⋅ =

slide-16
SLIDE 16

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Triangular Distribution Inverse-transform Technique – Triangular Distribution

  • The CDF of a Triangular

g Distribution with endpoints (0, 2) is given by

⎪ ⎪ ⎧ ≤ ≤ 1

2

X X

⎪ ⎧ ≤ 0

2

x x

⎪ ⎪ ⎩ ⎪ ⎪ ⎨ ≤ ≤ − − ≤ ≤ = 2 1 2 ) 2 ( 1 1 2 ) (

2

X X X X R

⎪ ⎪ ⎪ ⎪ ⎪ ⎨ ≤ < − − ≤ < = 2 1 ) 2 ( 1 1 2 ) (

2

x x x x x F

  • X is generated by

⎪ ⎩ 2

⎪ ⎪ ⎪ ⎩ > ≤ < 2 1 2 1 2 1 x x

  • X is generated by

⎪ ⎨ ⎧ ≤ ≤ = 2

2 1

R R X

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 16

⎪ ⎩ ⎨ ≤ < − − 1 ) 1 ( 2 2

2 1

R R X

slide-17
SLIDE 17

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Empirical Continuous Distributions Inverse-transform Technique – Empirical Continuous Distributions

  • When theoretical distributions are not applicable

e eo e ca d s bu o s a e

  • app cab e
  • To collect empirical data:
  • Resample the observed data
  • Interpolate between observed data points to fill in the gaps
  • Interpolate between observed data points to fill in the gaps
  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 17

slide-18
SLIDE 18

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Empirical Continuous Distributions Inverse-transform Technique – Empirical Continuous Distributions

  • For a small sample set (size n):

p ( )

  • Arrange the data from smallest to largest

(n) (2) (1)

x x x ≤ … ≤ ≤

  • Set x(0)=0
  • Assign the probability 1/n to each interval
  • The slope of each line segment is defined as

n i , , 2 , 1 x x x

(i) 1)

  • (i

K = ≤ ≤

The slope of each line segment is defined as

x x i i x x a

i i i i i

1 ) 1 (

) 1 ( ) ( ) 1 ( ) ( − −

− = − − − =

  • The inverse CDF is given by

⎞ ⎛ i ) 1 (

n n n

i i ) 1 (

⎟ ⎠ ⎞ ⎜ ⎝ ⎛ − − + = =

− −

n i R a x R F X

i i

) 1 ( ) ( ˆ

) 1 ( 1

n i R n i ≤ < − ) 1 (

when

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 18

slide-19
SLIDE 19

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Empirical Continuous Distributions Inverse-transform Technique – Empirical Continuous Distributions

i Interval PDF CDF Slope ai 1 0.0 < x ≤ 0.8 0.2 0.2 4.00 2 0.8 < x ≤ 1.24 0.2 0.4 2.20 3 1.24 < x ≤ 1.45 0.2 0.6 1.05 4 1.45 < x ≤ 1.83 0.2 0.8 1.90 5 1.83 < x ≤2.76 0.2 1.0 4.65

) / ) 1 4 ( ( 71 .

1 4 ) 1 4 ( 1 1

− − + = =

n R a x X R 66 . 1 ) 6 . 71 . ( 90 . 1 45 . 1 = − + =

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 19

slide-20
SLIDE 20

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Empirical Continuous Distributions Inverse-transform Technique – Empirical Continuous Distributions

What happens for large samples of data What happens for large samples of data

  • Several hundreds or tens of thousand

First summarize the data into a frequency distribution with smaller number of intervals Afterwards, fit continuous empirical CDF to the frequency distribution distribution Slight modifications

  • Slope

Slope

) 1 ( ) ( −

− − =

i i i

c c x x a

ci cumulative probability of the first i intervals

  • The inverse CDf is given by

1 −

i i

c c

( )

1

ˆ

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 20

( )

i i i i i

c R c c R a x R F X ≤ < − + = =

− − − − 1 1 ) 1 ( 1

when ) (

slide-21
SLIDE 21

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Empirical Continuous Distributions Inverse-transform Technique – Empirical Continuous Distributions

  • Example: Suppose the data collected for 100 broken-widget repair

p pp g p times are:

Interval (Hours) Frequency Relative Frequency Cumulative Frequency, c i Slope, a i 0.25 ≤ x ≤ 0.5 31 0.31 0.31 0.81 0.5 ≤ x ≤ 1.0 10 0.10 0.41 5.00 1.0 ≤ x ≤ 1.5 25 0.25 0.66 2.00 1.5 ≤ x ≤ 2.0 34 0.34 1.00 1.47

Consider R1 = 0.83: c3 = 0.66 < R1 < c4 = 1.00 X1 = x(4-1) + a4(R1 – c(4-1)) = 1.5 + 1.47(0.83-0.66) = 1.75

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 21

slide-22
SLIDE 22

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Empirical Continuous Distributions Inverse-transform Technique – Empirical Continuous Distributions

Problems with empirical distributions Problems with empirical distributions

  • The data in the previous example is restricted in the range

0.25 ≤ X ≤ 2.0

  • The underlying distribution might have a wider range
  • Thus, try to find a theoretical distribution

Hints for building empirical distributions based on frequency tables

  • It is recommended to use relatively short intervals
  • Number of bins increase

Thi ill lt i t ti t

  • This will result in a more accurate estimate
  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 22

slide-23
SLIDE 23

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Continuous Distributions Inverse-transform Technique – Continuous Distributions A number of continuous distributions do not have a closed A number of continuous distributions do not have a closed form expression for their CDF, e.g.

( )

( )

x

  • Normal
  • Gamma
  • Beta

( )

( )dt

x F

t

exp ) (

2 2 1 2 1

∞ − −

− =

σ μ π σ

  • Beta

The presented method does not work for these distributions Solution Solution

  • Approximate the CDF or numerically integrate the CDF

Problem

  • Computationally slow
  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 23

slide-24
SLIDE 24

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Discrete Distribution Inverse-transform Technique – Discrete Distribution All discrete distributions can be generated via inverse-transform All discrete distributions can be generated via inverse transform technique Method: numerically, table-lookup procedure, algebraically, or a formula Examples of application:

E i i l

  • Empirical
  • Discrete uniform
  • Geometric

Geometric

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 24

slide-25
SLIDE 25

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Discrete Distribution Inverse-transform Technique – Discrete Distribution Example: Suppose the number of shipments, x, on the p pp p , , loading dock of a company is either 0, 1, or 2

  • Data - Probability distribution:

x p(x) F(x)

0,50 0,50 1 0 30 0 80

The inverse transform technique as table lookup procedure

1 0,30 0,80 2 0,20 1,00

The inverse-transform technique as table-lookup procedure

) ( ) (

1 1 i i i i

x F r R r x F = ≤ < =

  • Set X = xi

) ( ) (

1 1 i i i i

x F r R r x F ≤ <

− −

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 25

slide-26
SLIDE 26

Computer Science, Informatik 4 Communication and Distributed Systems

Inverse-transform Technique – Discrete Distribution Inverse-transform Technique – Discrete Distribution

Method - Given R, the

5 ≤ ⎧ R

Method Given R, the generation scheme becomes:

. 1 8 . 8 . 5 . 5 . , 2 , 1 , ≤ < ≤ < ≤ ⎪ ⎩ ⎪ ⎨ ⎧ = R R R x

Consider R 0 73:

, ⎩

Table for generating the Consider R1 = 0.73: F(xi-1) < R ≤ F(xi) F(x0) < 0.73 ≤ F(x1) Hence, X1 = 1

i Input ri Output xi

Table for generating the discrete variate X

1

1 0.5 2 0.8 1

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 26

3 1.0 2

slide-27
SLIDE 27

Computer Science, Informatik 4 Communication and Distributed Systems

Acceptance-Rejection Technique Acceptance Rejection Technique

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 27

slide-28
SLIDE 28

Computer Science, Informatik 4 Communication and Distributed Systems

Acceptance-Rejection Technique Acceptance-Rejection Technique

  • Useful particularly when inverse cdf does not exist in closed form

Useful particularly when inverse cdf does not exist in closed form

  • Thinning
  • Illustration: To generate random variates, X ~ U(1/4,1)

Procedures: Step 1 Generate R U[0 1]

Generate R

no

Step 1. Generate R ~ U[0,1] Step 2. If R ≥ ¼, accept X=R. Step 3. If R < ¼, reject R, return to Step 1

Condition

yes

  • R does not have the desired distribution, but R conditioned (R’) on the

Step 3. If R ¼, reject R, return to Step 1

Output R’

R does not have the desired distribution, but R conditioned (R ) on the event {R ≥ ¼} does.

  • Efficiency: Depends heavily on the ability to minimize the number of

j ti

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 28

rejections.

slide-29
SLIDE 29

Computer Science, Informatik 4 Communication and Distributed Systems

Acceptance-Rejection Technique – Poisson Distribution Acceptance-Rejection Technique – Poisson Distribution

  • Probability mass function of a Poisson Distribution

y

α

α

= = e n n N P

n

! ) (

  • Exactly n arrivals during one time unit

1 2 1 2 1

1

+

+ + + + < ≤ + + +

n n n

A A A A A A A L L

  • Since interarrival times are exponentially distributed we can set

W ll k d i d thi t i th b i i f th l

α ) ln(

i i

R A − =

  • Well known, we derived this generator in the beginning of the class
  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 29

slide-30
SLIDE 30

Computer Science, Informatik 4 Communication and Distributed Systems

Acceptance-Rejection Technique – Poisson Distribution Acceptance-Rejection Technique – Poisson Distribution Substitute the sum by Substitute the sum by

∑ ∑

+ = =

− < ≤ −

1 1 1

) ln( 1 ) ln(

n i i n i i

R R α α

Simplify by

  • multiply by -α, which reverses the inequality sign

= = 1 1 i i

  • sum of logs is the log of a product

∑ ∑

+

> − ≥

n i n i

R R

1

) ln( ) ln( α

∏ ∏ ∑ ∑

= =

> − ≥

n i n i i i

R R

1 1

ln ln α Simplify by eln(x) = x

∏ ∏

+ − >

1 n i n i

R e R

α = = i i 1 1

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 30

∏ ∏

= = 1 1 i i i i

e

slide-31
SLIDE 31

Computer Science, Informatik 4 Communication and Distributed Systems

Acceptance-Rejection Technique – Poisson Distribution Acceptance-Rejection Technique – Poisson Distribution

  • Procedure of generating a Poisson random variate N is as

Procedure of generating a Poisson random variate N is as follows

  • 1. Set n=0, P=1
  • 2. Generate a random number Rn+1, and replace P by P x Rn+1
  • 3. If P < exp(-α), then accept N=n

Otherwise reject the current n increase n by one and return to

  • Otherwise, reject the current n, increase n by one, and return to

step 2.

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 31

slide-32
SLIDE 32

Computer Science, Informatik 4 Communication and Distributed Systems

Acceptance-Rejection Technique – Poisson Distribution Acceptance-Rejection Technique – Poisson Distribution

  • Example: Generate three Poisson variates with mean α=0.2
  • exp(-0.2) = 0.8187
  • Variate 1
  • Step 1: Set n = 0, P = 1
  • Step 2: R1 = 0.4357, P = 1 x 0.4357
  • Step 3: Since P = 0.4357 < exp(- 0.2), accept N = 0
  • Variate 2
  • Step 1: Set n = 0, P = 1
  • Step 2: R1 = 0.4146, P = 1 x 0.4146
  • Step 3: Since P = 0.4146 < exp(-0.2), accept N = 0

V i t 3

  • Variate 3
  • Step 1: Set n = 0, P = 1
  • Step 2: R1 = 0.8353, P = 1 x 0.8353

Step 3: Since P 0 8353 > ( 0 2) reject 0 and return to Step 2 with 1

  • Step 3: Since P = 0.8353 > exp(-0.2), reject n = 0 and return to Step 2 with n = 1
  • Step 2: R2 = 0.9952, P = 0.8353 x 0.9952 = 0.8313
  • Step 3: Since P = 0.8313 > exp(-0.2), reject n = 1 and return to Step 2 with n = 2
  • Step 2: R3 = 0 8004 P = 0 8313 x 0 8004 = 0 6654
  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 32

  • Step 2: R3 = 0.8004, P = 0.8313 x 0.8004 = 0.6654
  • Step 3: Since P = 0.6654 < exp(-0.2), accept N = 2
slide-33
SLIDE 33

Computer Science, Informatik 4 Communication and Distributed Systems

Acceptance-Rejection Technique – Poisson Distribution Acceptance-Rejection Technique – Poisson Distribution It took five random numbers to generate three Poisson It took five random numbers to generate three Poisson variates In long run, the generation of Poisson variates requires some

  • verhead!

N Rn+1 P Accept/Reject Result

0.4357 0.4357 P < exp(- α) Accept N=0 0.4146 0.4146 P < exp(- α) Accept N=0 0.8353 0.8353 P ≥ exp(- α) Reject 1 0.9952 0.8313 P ≥ exp(- α) Reject 1 0.9952 0.8313 P ≥ exp( α) Reject 2 0.8004 0.6654 P < exp(- α) Accept N=2

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 33

slide-34
SLIDE 34

Computer Science, Informatik 4 Communication and Distributed Systems

Special Properties Special Properties

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 34

slide-35
SLIDE 35

Computer Science, Informatik 4 Communication and Distributed Systems

Special Properties Special Properties Based on features of particular family of probability Based on features of particular family of probability distributions For example:

  • Direct Transformation for normal and lognormal distributions
  • Convolution
  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 35

slide-36
SLIDE 36

Computer Science, Informatik 4 Communication and Distributed Systems

Direct Transformation Direct Transformation

Approach for N(0,1) Approach for N(0,1)

  • PDF

2

2

1 ) (

x

e x f

=

  • CDF, No closed form available

2

2 ) ( e x f = π

∞ − −

=

x t

dt e x F

2

2

2 1 ) ( π

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 36

slide-37
SLIDE 37

Computer Science, Informatik 4 Communication and Distributed Systems

Direct Transformation

Approach for N(0 1)

Direct Transformation

Approach for N(0,1)

  • Consider two standard normal random variables, Z1 and Z2, plotted as a

point in the plane:

  • In polar coordinates:
  • Z1 = B cos(α)
  • Z2 = B sin(α)

Z2 B sin(α)

(Z1,Z2) Z2

B

α Z1

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 37

Z1

slide-38
SLIDE 38

Computer Science, Informatik 4 Communication and Distributed Systems

Direct Transformation Direct Transformation Chi-square distribution Chi square distribution

  • Given k independent N(0, 1) random variables X1, X2, …, Xk, then

the sum is according chi-square distribution

=

k i i k

X

1 2 2

χ

  • PDF

= i 1

( )

2 2 2

1

2 1 ) , (

x k k

e x k x f

k − −

Γ = ( )

2

2 2 k

Γ

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 38

slide-39
SLIDE 39

Computer Science, Informatik 4 Communication and Distributed Systems

Direct Transformation Direct Transformation

The following relationships are known The following relationships are known

  • B2 = Z2

1 + Z2 2 ~ χ2 distribution with 2 degrees of freedom = exp(λ = 1/2).

  • Hence,

R B ln 2 − =

  • The radius B and angle α re mutually independent.

) 2 cos( ln 2 R R Z π − = ) 2 sin( ln 2 ) 2 cos( ln 2

2 1 2 2 1 1

R R Z R R Z π π − = − =

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 39

slide-40
SLIDE 40

Computer Science, Informatik 4 Communication and Distributed Systems

Direct Transformation Direct Transformation Approach for N(μ,σ2): pp (μ, )

  • Generate Zi ~ N(0,1)

Xi = μ + σ Zi

Approach for Lognormal(μ,σ2): pp g (μ, )

  • Generate X ~ N(μ,σ2)

Y = eXi Yi = e i

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 40

slide-41
SLIDE 41

Computer Science, Informatik 4 Communication and Distributed Systems

Direct Transformation – Example Direct Transformation – Example Let R1 = 0.1758 and R2=0.1489 Let R1 0.1758 and R2 0.1489 Two standard normal random variates are generated as follows:

50 . 1 ) 1489 . 2 sin( ) 1758 . ln( 2 11 . 1 ) 1489 . 2 cos( ) 1758 . ln( 2

2 1

= − = = − = π π Z Z

To obtain normal variates Xi with mean μ=10 and variance σ2=4 σ2=4

22 . 12 11 . 1 2 10

1

= ⋅ + = X 00 . 13 50 . 1 2 10

2

= ⋅ + = X

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 41

slide-42
SLIDE 42

Computer Science, Informatik 4 Communication and Distributed Systems

Convolution Convolution Convolution Convolution

  • The sum of independent random variables

Can be applied to obtain

  • Erlang variates
  • Binomial variates
  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 42

slide-43
SLIDE 43

Computer Science, Informatik 4 Communication and Distributed Systems

Convolution Convolution Erlang Distribution Erlang Distribution

  • Erlang random variable X with parameters (k, θ) can be depicted

as the sum of k independent exponential random variables Xi, i = 1 k h h i 1/(k θ) 1, …, k each having mean 1/(k θ)

k

=∑

= k i i

X X

1

1 ⎞ ⎛ − =∑

= k i i

R k

1

1 ) ln( 1 θ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ − =

= k i i

R k

1

ln 1 θ

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 43

slide-44
SLIDE 44

Computer Science, Informatik 4 Communication and Distributed Systems

Summary Summary Principles of random-variate generation via Principles of random variate generation via

  • Inverse-transform technique
  • Acceptance-rejection technique
  • Special properties

I f i i d di di ib i Important for generating continuous and discrete distributions

  • Dr. Mesut Güneş

Chapter 7. Random-Variate Generation 44