CPE 345: Modeling and simulation - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

CPE 345: Modeling and simulation

Description:

Buying more scanning machines may reduce the queueing time for queue 1 ... (b) Run a chi-square test to determine if the distribution ... Chi-square test-cont. ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 24
Provided by: Cris336
Category:

less

Transcript and Presenter's Notes

Title: CPE 345: Modeling and simulation


1
CPE 345 Modeling and simulation
  • Lecture 12

2
Todays topics
  • Sample final
  • interactive problem solving

3
Problem 1
  • We would like to generate a sequence of 200
    uniformly distributed random numbers, using a
    linear congruential random number generator with
    parameters a 11, and c0.
  • We want to implement a maximum period
    generator.
  • (a) What is the minimum value for m that we can
    use such that the 200 numbers generated should
    not repeat?
  • (b) What additional condition you need such that
    the period of the generator would be greater than
    200?

4
What do we know ?
  • N 200 numbers. We want P gt N 200 (maximal
    length)
  • a 11, c0, m ?
  • Linear congruential generator
  • Properties - Maximum period generator conditions
  • For m 2b, and c?0, the longest possible period
    is P m 2b, achieved if c is relatively prime
    to m (the greatest common factor of c and m is
    1), and a 14k, k integer.
  • For m 2b, and c 0, the longest possible
    period is P m/4 2b-2, achieved if the seed X0
    is odd, and a 38k or a 58k, k0,1,
  • For m a prime number and c 0, the longest
    possible period is P m-1, achieved if a has the
    property that the smallest integer k s.t. ak-1 is
    divisible by m is k m-1.

5
Problem 1 solution
  • Answer
  • (a)
  • (b) Additional condition?
  • For m 2b, and c 0, the longest possible
    period is P m/4 2b-2, achieved if the seed X0
    is odd, and a 38k or a 58k, k0,1,
  • The seed X0 should be selected to be an odd
    number
  • e.g. X0 5

6
Problem 2
  • At a Supermarket express line, self-checkout is
    employed there are two scanning machines, that
    each customer can use, and then the customers get
    a receipt and need to pay to a physical person,
    which serves both queues. Assume that the
    customers arrive with a Poisson distribution of
    ? 0.1 per minute, and the time required for
    each self-scanning order (one customer service)
    is exponential distributed with mean 1/?10
    minutes, also the time of service for the
    physical cashier person is also exponentially
    distributed with mean 1/?1 minute.
  • (a) Draw the queueing system
  • (b) Is this system stable? Motivate your
    answer using formulas.
  • (c) What is the average delay experienced by
    the customers?
  • (d) How could you improve the system (reduce
    the delay)?
  • (e) Suppose you want to estimate the
    customers delay by means of simulations. After
    the arrival of 10000 customers, you may compute
    an estimator for the average delay experienced by
    the customers. How accurate you may expect your
    estimator to be approximately (e.g. in the order
    of 0.1 (1 decimal accuracy), 0.01 (two decimals),
    0.001 (3 decimals), etc.)?

7
What do we know?
  • Self checkout pay cashier
  • Self-checkout infinite number of servers ?
  • No! We have only 2 scanning machines!
  • Poisson arrivals ? 0.1 per minute
  • Exponential service times
  • Self scanning 1/?10 minutes ? ?s 0.1
  • Cashier 1/?1 minute ? ?C 1

8
Stability
  • (b) Stable if both queues are stable
  • First queue M/M/2 ? ?1 ?/c?s ?/2?s
    0.1/0.2 0.5 ? stable
  • Second queue M/M/1 ? ?2 ?/?C 0.1/1 0.1 ?
    stable

9
Average delay
w1
  • w w1w2
  • First queue M/M/2

w2
10
Average delay continued
  • Second queue M/M/1
  • Delay given mostly by the self-checkout queue
  • Buying more scanning machines may reduce the
    queueing time for queue 1
  • Not a significant reduction though the
    bottleneck is the speed of the customers
    operating the self-scanning machines

11
Simulation performance
  • (e) Suppose you want to estimate the customers
    delay by means of simulations. After the arrival
    of 10000 customers, you may compute an estimator
    for the average delay experienced by the
    customers. How accurate you may expect your
    estimator to be approximately (e.g. in the order
    of 0.1 (1 decimal accuracy), 0.01 (two decimals),
    0.001 (3 decimals), etc.)?
  • Standard error
  • Your accuracy is in the order of 1/sqrt(10000)
    0.01

12
Problem 3
  • We have analyzed a computer network performance
    based on the assumption that the traffic
    generated at the output of each server is
    exponentially distributed. To validate that, we
    experimentally build a histogram as in the figure

Estimated mean
5-6
7-8
9-10
8-9
(a) Can you estimate the mean of the
distribution? (b) Run a chi-square test to
determine if the distribution is indeed
exponential. The desired significance level is ?
0.05.
13
Chi-square test
  • Exponential expected mean 1/? 6.26, Ei npi
  • n 50 samples,

(ai, bi) Oi Ei (Oi-Ei)2/Ei
5-6 27 3.32 169.55
6-7 13 2.83 36.74
7-8 6 2.43 5.296
8-9 3 2.07 0.42
9-10 1 1.76 0.33
Total 50 12.37 212.34
For ? 0.05 ? critical value is 7.815 ? the
exponential distrib. hypothesis is rejected
14
Chi-square test-cont.
  • The critical value (7.815) was obtained from the
    table chi_square_critical_value.doc, for ?
    0.05, and the number of degrees of freedom,
  • k number of cells
  • s number of parameters estimated (we have
    estimated the mean)
  • If (Oi-Ei)2/Ei gt critical value, the hypothesis
    is rejected
  • 212.34 gt 7.815 ? distribution is not exponential

15
Problem 4
  • By analyzing a very complex computer network, you
    find that the average delay experienced by each
    packet in queue i can be determined as
  • where n is the total number of queues in the
    network, each having arrival rates ?i and service
    rates ?i.
  • Is this formula valid on its face?
  • What other validity tests can you use? Is this
    formula valid according to these new tests?

16
Face validity
  • Units test rate2/(raterate) ? units test
    passed
  • Does model behavior change in expected ways with
    modification of parameters?
  • if arrival rate in queue i , then wi ?
  • if service rate for queue i , then wi
    ?
  • if total arrival in the other queues is 0, wi ?
    ? ?
  • The formula is not valid on its face
  • Other test some form of Turing test observe
    delay produce by the real system, compare with
    the computed expected value - we expect the
    validity test to fail

(b)
17
Problem 5
  • We are designing a simulation in which we have
    implemented an exponential random number
    generator. To validate this generator, we collect
    its outputs and generate a histogram. If the
    generated exponential r.v. has mean 5, and we
    select 10 cells for the histogram of width 1, and
    the range starts at 3, what is the probability
    that the random number generated may fall outside
    the range?
  • Range 3, 13

18
Problem 6
  • Suppose you are simulating the delay experienced
    by the customers of a bank with one single
    teller. If customers arrive with a rate of 1
    every 15 minutes (and the arrivals are Poisson
    distributed), and the tellers service is
    exponentially distributed with mean 10 minutes,
  • (a) Determine the 95 confidence interval for
    delay estimation, if the simulation has collected
    100 samples in 4 different runs, and the obtained
    values for the delay are
  • w1 31.2 w2 29.42 w3 33.1 w4 28.7.

19
What do we know?
  • N 100 samples, 4 runs ? 25 samples/run
  • Arrivals Poisson, ? 1/15
  • Departures exponential ? 0.1
  • Average delays for the 4 runs w1 31.2 w2
    29.42 w3 33.1 w4 28.7.
  • Need to determine 95 confidence intervals
  • Lots of redundant information!

20
Confidence intervals
  • A 100(1-?) confidence interval is given by
  • With f R-1 3
  • Need to determine
  • ? ? 100(1-?) 95 ? ? 0.05
  • 3.18 (Table A.5. appendix in your
    book)

21
Confidence intervals
run Delay
1 31.2
2 29.42
3 33.1
4 28.7
22
Confidence intervals cont.
  • The 95 confidence interval
  • For extra credit, you may compute the theoretical
    delay and compare the results M/M/1

23
Next class
  • Projects are due
  • Final in class open books, open notes
  • Good luck to everybody!
Write a Comment
User Comments (0)
About PowerShow.com