Computer Science, Informatik 4 Communication and Distributed Systems
Simulation
“Discrete-Event System Simulation”
- Dr. Mesut Güneş
Simulation Discrete-Event System Simulation Dr. Mesut Gne Computer - - PowerPoint PPT Presentation
Computer Science, Informatik 4 Communication and Distributed Systems Simulation Discrete-Event System Simulation Dr. Mesut Gne Computer Science, Informatik 4 Communication and Distributed Systems Chapter 6 Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems
Computer Science, Informatik 4 Communication and Distributed Systems
Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems 3 Chapter 6. Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems 4 Chapter 6. Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems 5 Chapter 6. Random-Variate Generation
x = F-1(r)
r1 x1
r = F(x)
x F(x) 1 r1 x1
r = F(x)
x F(x) 1
Computer Science, Informatik 4 Communication and Distributed Systems 6 Chapter 6. Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems 7 Chapter 6. Random-Variate Generation
x
λ
−
x
λ −
1 R
X X − − −
λ λ
uniformly distributed on [0,1]
Computer Science, Informatik 4 Communication and Distributed Systems 8 Chapter 6. Random-Variate Generation
Figure: Inverse-transform technique for exp(λ = 1)
Computer Science, Informatik 4 Communication and Distributed Systems 9 Chapter 6. Random-Variate Generation
1 1
0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,5 1 1,5 2 2,5 3 3,5 4 4,5 5 5,5 6 6,5 7 Empirical Histogram
Computer Science, Informatik 4 Communication and Distributed Systems 10 Chapter 6. Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems 11 Chapter 6. Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems 12 Chapter 6. Random-Variate Generation
β α x
−
( ) ( )
β β β β β β β β α
β α β α
X
X X
− −
( )
β α
β β
x
− −
1
Computer Science, Informatik 4 Communication and Distributed Systems 13 Chapter 6. Random-Variate Generation
2 2
2 2
2 1 2 1
Computer Science, Informatik 4 Communication and Distributed Systems 14 Chapter 6. Random-Variate Generation
(n) (2) (1)
(i) 1)
− −
i i
) 1 ( 1
n x x n i n x x a
i i i i i
/ 1 / ) 1 ( / 1
) 1 ( ) ( ) 1 ( ) ( − −
− = − − − =
Computer Science, Informatik 4 Communication and Distributed Systems 15 Chapter 6. Random-Variate Generation
4.65 1.0 0.2 1.83 < x ≤2.76 5 1.90 0.8 0.2 1.45 < x ≤ 1.83 4 1.05 0.6 0.2 1.24 < x ≤ 1.45 3 2.20 0.4 0.2 0.8 < x ≤ 1.24 2 4.00 0.2 0.2 0.0 < x ≤ 0.8 1 Slope ai Cumulative Probability Probability Interval i
1 4 ) 1 4 ( 1 1
−
Computer Science, Informatik 4 Communication and Distributed Systems 16 Chapter 6. Random-Variate Generation
1 ) 1 ( ) ( − −
i i i i i
1 ) 1 ( 1
− − −
i i i
ci cumulative probability of the first i intervals
Computer Science, Informatik 4 Communication and Distributed Systems 17 Chapter 6. Random-Variate Generation
i Interval (Hours) Frequency Relative Frequency Cumulative Frequency, c i Slope, a i 1 0.25 ≤ x ≤ 0.5 31 0.31 0.31 0.81 2 0.5 ≤ x ≤ 1.0 10 0.10 0.41 5.0 3 1.0 ≤ x ≤ 1.5 25 0.25 0.66 2.0 4 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
Computer Science, Informatik 4 Communication and Distributed Systems 18 Chapter 6. Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems 19 Chapter 6. Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems 20 Chapter 6. Random-Variate Generation
x p(x) F(x)
0.50 0.50 1 0.30 0.80 2 0.20 1.00
1 1 i i i i
− −
Computer Science, Informatik 4 Communication and Distributed Systems 21 Chapter 6. Random-Variate Generation
Consider R1 = 0.73: F(xi-1) < R <= F(xi) F(x0) < 0.73 <= F(x1) Hence, x1 = 1
Method - Given R, the generation scheme becomes:
Table for generating the discrete variate X
Computer Science, Informatik 4 Communication and Distributed Systems 22 Chapter 6. Random-Variate Generation
Generate R Condition Output R’
yes no
Computer Science, Informatik 4 Communication and Distributed Systems 23 Chapter 6. Random-Variate Generation
α
−
n
1 2 1 2 1
+
n n n
i i
Computer Science, Informatik 4 Communication and Distributed Systems 24 Chapter 6. Random-Variate Generation
+ = − =
1 1 1 n i i n i i
α
+ = =
1 1 1
n i i n i i
= + = = =
n i i n i i n i i n i i
1 1 1 1 1
Computer Science, Informatik 4 Communication and Distributed Systems 25 Chapter 6. Random-Variate Generation
step 2.
Computer Science, Informatik 4 Communication and Distributed Systems 26 Chapter 6. Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems 27 Chapter 6. Random-Variate Generation
N=2 Accept P < exp(- α) 0.6654 0.8004 2 Reject P ≥ exp(- α) 0.8313 0.9952 1 Reject P ≥ exp(- α) 0.8353 0.8353 N=0 Accept P < exp(- α) 0.4146 0.4146 N=0 Accept P < exp(- α) 0.4357 0.4357
Computer Science, Informatik 4 Communication and Distributed Systems 28 Chapter 6. Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems 29 Chapter 6. Random-Variate Generation
point in the plane:
1 + Z2 2 ~ χ2 distribution with 2 degrees of freedom = Exp(λ = 2).
Hence,
2 / 1
In polar coordinates: Z1 = B cos(φ) Z2 = B sin(φ) ) 2 sin( ) ln 2 ( ) 2 cos( ) ln 2 (
2 2 / 1 2 2 2 / 1 1
R R Z R R Z π π − = − =
Computer Science, Informatik 4 Communication and Distributed Systems 30 Chapter 6. Random-Variate Generation
Computer Science, Informatik 4 Communication and Distributed Systems 31 Chapter 6. Random-Variate Generation