ExpoSumMinMaxB

Embed Size (px)

Citation preview

  • 8/3/2019 ExpoSumMinMaxB

    1/9

    Demonstrations With Exponential Distributions

    Problem Sum of Exponentials:

    Suppose that a bank teller takes an exponentially distributed length of

    time with mean = 4 minutes to serve each customer and

    that the service times for different customers are independent.

    The teller is busy with a customer now and

    you are next in line.

    What is the probability that it will take

    more than 12 minutes before you are finished being served?

    Formulation:

    X 1 ~ EXPM(4) is the length of time before the current customer finishes.

    Because the exponential distribution has the "no memory" property,

    it makes no difference how long the customer has been

    with the teller before you arrive.

    X 2 ~ EXPM(4) is the length of time it will

    take to serve you once you advance to the teller.

    The random variables X 1 and X 2 are independent.

    T = X 1 + X 2 is the total length of time before you are finished.

  • 8/3/2019 ExpoSumMinMaxB

    2/9

    Exact Solution:

    From moment generating functions it is apparent that

    T ~ GAMMA(2, 4).

    We seek P{ T > 12} = 1 P{ T 12}

    1 - pgamma(12, 2, 1/4) returns

    [1] 0.1991483

    Thus the probability is about 20% that it will be

    more than 12 minutes before you are finished.

    Simulation

    The following R code simulates the distribution of T

    based on the sum of two exponential random variables,

    and estimates the probability that T > 12.

    Because we got an exact solution above,

    the point here is more to demonstrate graphically

    that the sum of two independent exponentials

    with the same mean is gamma distributed.

    "Knowing" that this is true because of an argument

    using generating functions doesn't always serve

    to give an intuitive feeling for what is going on.

  • 8/3/2019 ExpoSumMinMaxB

    3/9

    m

  • 8/3/2019 ExpoSumMinMaxB

    4/9

    Exercise 1:

    (a) What is the probability you will take longer than 12 min. if there is

    one customer ahead of you in line? Use R to get the exact answer.

    (b) Use Chebyshev's inequality to approximate the probability you will

    take more than 30 min. Also use Markov's inequality.

    Compare with the exact answer. [Note: You will need to find the

    mean and the standard deviation of the gamma waiting time

    distribution.]

    (c) Simulate the appropriate gamma and the probabilities for longer

    than 12 min. and longer than 30 min.

  • 8/3/2019 ExpoSumMinMaxB

    5/9

    Second Problem Minimum of Exponentials.

    A bank has two tellers, each with exponential service times

    with mean 4 min.

    Both tellers are busy now.You will start being served as soon as

    one of the tellers has finished.

    What is the probability that it will be

    more than five minutes before you start being served.

    Formulation:

    You seek the distribution of the random variable

    V = min( X 1, X 2), where X 1 and X 2 are indep. EXP(4).

    Exact Solution:

    1 F V (t ) = P{ V > t } = P{ X 1 > t , X 2 > t } = P{ X 1 > t }P{ X 2 > t }

    = (et/ ) (et/ ) = e2 t/ .

    Differentiating F V (t ) = 1 e2 t/ , we get f V (t ) = (2 /) e

    2 t/ .

    We recognize this as the pdf of an exponential distribution

    with mean 4 /2 = 2 min.

    V ~ EXP(2), so P{ V > 5} = e5/2 = 0.082085.

    In R: 1 - pexp(5, 1/2) returns 0.082085.

  • 8/3/2019 ExpoSumMinMaxB

    6/9

    Simulation

    m

  • 8/3/2019 ExpoSumMinMaxB

    7/9

    Third Problem Maximum of Exponentials

    There are two tellers in a bank exponential service times with mean

    4 min. as before. It is closing time.

    No one is waiting in line, but both tellers are busy.Everyone can go home when the last customer leaves.

    What is the probability that takes more than 5 minutes?

    Formulation:

    You seek the distribution of maximum W of the two exponentials.

    F W (t ) = P{ W t } = P{ X 1 t , X 2 t } = P{ X 1 t } P{ X 2 t }

    (1 et / )(1 et / ) = 1 2 et / + e2 t / .

    It is possible to find the pdf by differentiating, but the result is not an

    exponential density:

    f W (t ) = (2/ ) et / (2 / ) e2 t / = (2 / )( et / e2 t / ), for t > 0.

    This can be integrated over the interval (5, ) to give the answer.

    [See Exercise 3(a).]

    Note: It is clear that the maximum cannot have an exponentialdistribution because it does not have the "no memory" property:After some time elapses it might be that one of the tellers hasfinished, in which case starting at a later time is not like startingwhen both tellers are busy.

  • 8/3/2019 ExpoSumMinMaxB

    8/9

    Simulation:

    The simulation requires only slight modifications of the code

    we used for the minimum. R has no built-in density function for the max

    of exponentials. m

  • 8/3/2019 ExpoSumMinMaxB

    9/9

    Exercise 3:

    (a) Use the pdf of W to find an exact value of P{ W > 5}.Compare it with the simulated value obtained above.

    (b) For what value a is P( W > 5) = 1/2 ? This value is the median of W .

    [Answer: 4.911789.] Run a simulation using the code above; compare

    your answer with the result R returns for quantile(w, .5) .

    (c) Use the pdf of W to find E( W ) and compare the answer with thesimulated value. [Answer: (1 + 1/2) = 6. For the run shown in the

    graph above, R returned 5.984365 for mean(w) .]

    Copyright 2004 by Bruce E. Trumbo. All rights reserved. Department of Statistics, CSU Hayward. Corrections/comments: [email protected]