simulation
play

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


  1. Computer Science, Informatik 4 Communication and Distributed Systems Simulation “Discrete-Event System Simulation” Dr. Mesut Güneş

  2. Computer Science, Informatik 4 Communication and Distributed Systems Chapter 6 Random-Variate Generation

  3. Computer Science, Informatik 4 Communication and Distributed Systems Purpose & Overview � Develop understanding of generating samples from a specified distribution as input to a simulation model. � Illustrate some widely-used techniques for generating random variates. • Inverse-transform technique • Acceptance-rejection technique • Special properties Dr. Mesut Güneş Chapter 6. Random-Variate Generation 3

  4. Computer Science, Informatik 4 Communication and Distributed Systems Preparation � It is assumed that a source of uniform [0,1] random numbers exists. • Linear Congruential Method � Random numbers R, R 1 , R 2 , … with • PDF ≤ ≤ ⎧ 1 0 x 1 = ⎨ f R ( x ) ⎩ 0 otherwise • CDF < ⎧ 0 0 x ⎪ = ≤ ≤ ⎨ F R ( x ) x 0 x 1 ⎪ > ⎩ 1 x 1 Dr. Mesut Güneş Chapter 6. Random-Variate Generation 4

  5. Computer Science, Informatik 4 Communication and Distributed Systems Inverse-transform Technique � 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) F(x) 1 1 r = F(x) r = F(x) r 1 r 1 x x x 1 x 1 Dr. Mesut Güneş Chapter 6. Random-Variate Generation 5

  6. Computer Science, Informatik 4 Communication and Distributed Systems Inverse-transform Technique 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. Required steps � 1. Compute the CDF of the desired random variable 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 R 1 , R 2 , R 3 , … and compute the desired random variate by X i = F -1 ( R i ) Dr. Mesut Güneş Chapter 6. Random-Variate Generation 6

  7. Computer Science, Informatik 4 Communication and Distributed Systems Exponential Distribution Exponential Distribution To generate X 1 , X 2 , X 3 … � � • PDF − λ − = X 1 e R − λ = λ x f ( x ) e − λ = − X 1 e R • CDF − λ = − = 1 − − λ X ln( 1 R ) x F ( x ) e − ln( 1 R ) = X − λ Simplification � − ln( 1 ) R = − X ln( R ) λ = − X λ 1 R − = X F ( ) • Since R and (1- R ) are uniformly distributed on [0,1] Dr. Mesut Güneş Chapter 6. Random-Variate Generation 7

  8. Computer Science, Informatik 4 Communication and Distributed Systems Exponential Distribution Figure: Inverse-transform technique for e xp( λ = 1) Dr. Mesut Güneş Chapter 6. Random-Variate Generation 8

  9. Computer Science, Informatik 4 Communication and Distributed Systems Exponential Distribution Example: Generate 200 variates X i with distribution exp( λ = 1) � • Generate 200 R s with U(0,1), the histogram of X s become: 0,7 0,6 0,5 0,4 0,3 0,2 0,1 0 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 • Check: Does the random variable X 1 have the desired distribution? ≤ = ≤ = P ( X x ) P ( R F ( x )) F ( x ) 1 0 1 0 0 Dr. Mesut Güneş Chapter 6. Random-Variate Generation 9

  10. Computer Science, Informatik 4 Communication and Distributed Systems Other Distributions � Examples of other distributions for which inverse CDF works are: • Uniform distribution • Weibull distribution • Triangular distribution Dr. Mesut Güneş Chapter 6. Random-Variate Generation 10

  11. Computer Science, Informatik 4 Communication and Distributed Systems Uniform Distribution � Random variable X uniformly distributed over [a, b] = F ( X ) R − X a = R − b a − = − X a R ( b a ) = + − X a R ( b a ) Dr. Mesut Güneş Chapter 6. Random-Variate Generation 11

  12. Computer Science, Informatik 4 Communication and Distributed Systems Weibull Distribution The Weibull Distribution is The variate is � � described by = F ( X ) R ( ) β − • PDF − X = α 1 e R β ( ) β − β − ( ) = x 1 β α f ( x ) x e − X = − β α α e 1 R ( ) β − = − X ln( 1 R ) α β • CDF X = − − ( ) ln( 1 R ) β − = 1 − x β α α ( ) F X e β = − α β ⋅ − X ln( 1 R ) β = β − α ⋅ − x ln( 1 R ) = α ⋅ − − β X ln( 1 R ) Dr. Mesut Güneş Chapter 6. Random-Variate Generation 12

  13. Computer Science, Informatik 4 Communication and Distributed Systems Triangular Distribution The CDF of a Triangular � Distribution with endpoints (0, 2) is given by ≤ ≤ For 0 X 1 ≤ ⎧ 0 x 0 ⎪ 2 2 X x = < ≤ R ⎪ 0 1 x ⎪ 2 2 = ⎨ F ( x ) − ≤ ≤ 2 ( 2 x ) and for 1 X 2 ⎪ − < ≤ 1 1 x 2 ⎪ − 2 2 ( 2 X ) ⎪ > = − ⎩ 1 x 2 R 1 2 X is generated by � ⎧ ≤ ≤ ⎪ 1 2 R 0 R = ⎨ 2 X ⎪ − − < ≤ 1 ⎩ 2 2 ( 1 R ) R 1 2 Dr. Mesut Güneş Chapter 6. Random-Variate Generation 13

  14. Computer Science, Informatik 4 Communication and Distributed Systems Empirical Continuous Distributions When theoretical distribution is not applicable � To collect empirical data: � • Resample the observed data • Interpolate between observed data points to fill in the gaps For a small sample set (size n ): � • Arrange the data from smallest to largest ≤ ≤ … ≤ x x x (1) (2) (n) • Set x (0) =0 ≤ ≤ • Assign the probability 1/n to each interval x x x (i - 1) (i) • The slope of each line segment is defined as − − x x x x − − = = ( i ) ( i 1 ) ( i ) ( i 1 ) a − − i 1 / n ( i 1 ) / n 1 / n • The inverse CDf is given by − ⎛ ⎞ ( i 1 ) = − = + − ˆ ⎜ ⎟ 1 X F ( R ) x a R − ( i 1 ) i ⎝ ⎠ n Dr. Mesut Güneş Chapter 6. Random-Variate Generation 14

  15. Computer Science, Informatik 4 Communication and Distributed Systems Empirical Continuous Distributions i Interval Probability Cumulative Probability Slope a i 0.0 < x ≤ 0.8 1 0.2 0.2 4.00 0.8 < x ≤ 1.24 2 0.2 0.4 2.20 1.24 < x ≤ 1.45 3 0.2 0.6 1.05 1.45 < x ≤ 1.83 4 0.2 0.8 1.90 1.83 < x ≤ 2.76 5 0.2 1.0 4.65 = R 0 . 71 1 = + − − X x a ( R ( 4 1 ) / n ) − 1 ( 4 1 ) 4 1 = + − 1 . 45 1 . 90 ( 0 . 71 0 . 6 ) = 1 . 66 Dr. Mesut Güneş Chapter 6. Random-Variate Generation 15

  16. Computer Science, Informatik 4 Communication and Distributed Systems Empirical Continuous Distributions � 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 � Slight modifications • Slope c i cumulative probability of − x x the first i intervals − = ( i ) ( i 1 ) a − i c c − i i 1 • The inverse CDf is given by ( ) − = = + − ˆ 1 ( ) X F R x a R c − − ( i 1 ) i i 1 Dr. Mesut Güneş Chapter 6. Random-Variate Generation 16

  17. Computer Science, Informatik 4 Communication and Distributed Systems Empirical Continuous Distributions Example: Suppose the data collected for 100 broken-widget repair � times are: Interval Relative Cumulative Slope, i (Hours) Frequency Frequency Frequency, c i 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 R 1 = 0.83: c 3 = 0.66 < R 1 < c 4 = 1.00 X 1 = x (4-1) + a 4 (R 1 – c (4-1) ) = 1.5 + 1.47(0.83-0.66) = 1.75 Dr. Mesut Güneş Chapter 6. Random-Variate Generation 17

  18. Computer Science, Informatik 4 Communication and Distributed Systems Empirical Continuous 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 distribution based on frequency tables • It is recommended to use relatively short intervals - Number of bin increase • This will result in a more accurate estimate Dr. Mesut Güneş Chapter 6. Random-Variate Generation 18

  19. Computer Science, Informatik 4 Communication and Distributed Systems Discrete Distribution � All discrete distributions can be generated via inverse-transform technique � Method: numerically, table-lookup procedure, algebraically, or a formula � Examples of application: • Empirical • Discrete uniform • Gamma Dr. Mesut Güneş Chapter 6. Random-Variate Generation 19

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend