Solving exponential distribution probability using Calculus
Category: Blog

Today I was challenged with the following advanced statistics problem:

Two variables are exponentially distributed with rate parameters lambda 1 ( λ1 ) and lambda 2 ( λ2 ). What is the probability ( p ) that variable 1 ( X1 ) is less than variable 2 ( X2 ) in terms of lambdas?

Being one who is usually up to a good challenge, this sounded like a fun Sunday task, especially as there are many practical applications of this knowledge (see end of post for one example). It sadly took me much longer than I anticipated, but I learned a lot along the way.

Let’s start off with some definitions. First off, we need to brush up a little bit on exponential distribution and we then can see that to get the probability that X1 < X2 for all possible legal values from zero to infinity, we use the following problem definition:

p = \int^\infty_0 P(X_2=x)P(X_1<x) dx

What it’s essentially saying is that the probability that X1 < X2 is the combined probability that X2 = x AND X1 < x. From there, we can do some simple replacements. To find the probability that X2 = x we use the Probability density function (PDF). Then to find the probability that X1 < x we use the Cumulative distribution function (CDF). Based on the definition that P(A and B) is the same as P(A)P(B), we end up with:

p = \int^\infty_0 PDF_{X_2}(x) CDF_{X_1}(x) dx

Next up, we need to do some substitutions for PDF and CDF respectively. According to Wikipedia, PDF is defined as:

definition of probability density function (PDF)

And CDF is defined as:

definition of cumulative distribution function (CDF)

So with that in mind, we now arrive at this:

p = \int^\infty_0 \lambda_2 e^{-\lambda_2 x}(1-e^{-\lambda_1 x}) dx

Before solving the integral, we will do some simplification. First up, using the distributive property of subtraction, we can simplify the above into this:

p = \int^\infty_0 \lambda_2 e^{-\lambda_2 x} dx - \lambda_2 e^{-\lambda_2 x} \lambda_2 e^{-\lambda_1 x} dx

After that, we will use exponential identities to refactor the problem down a bit further to this:

p = \int^\infty_0 \lambda_2  e^{-\lambda_2 x} dx - \lambda_2 e^{-\lambda_2 x - \lambda_1 x} dx

At this point, we can now proceed to solve the integral and using the definition that the integration of e^x = e^x and subsequently e^-x = -e^-x we end up with the following:

p = (-\frac{\lambda_2 e^{-\lambda_2 x}}{\lambda_2} + \frac{\lambda_2 e^{-\lambda_2 x - \lambda_1 x}}{\lambda_2 + \lambda_1})\Big |^\infty_0

After then doing some basic simplification of the fractions, we now end up with this:

p = (-e^{-\lambda_2 x} + \frac{\lambda_2 e^{-\lambda_2 x - \lambda_1 x}}{\lambda_2 + \lambda_1})\Big |^\infty_0

Next up, we need to apply the closed interval to the function using the fundamental theorem of calculus. The fundamental theorem states that when integrating f(x) over the interval [a,b] the result is F(b) – F(a) as seen here in this definition:

integrating f(x) over the interval [a,b] the result is F(b) - F(a)

When we apply the fundamental theorem to our equation it gives us this result:

p = (-\displaystyle\lim_{c\to{-\infty}}e^{\lambda_2 c} + \frac{\displaystyle\lim_{c\to{-\infty}} \lambda_2 e^{\lambda_2 c + \lambda_1 c}}{\lambda_2 + \lambda_1}) - (-e^0 + \frac{\lambda_2 e^0}{\lambda_2 + \lambda_1})

Next up, we now need to calculate the results of the exponential functions. By definition, with e raised to the power of c as c approaches negative infinity, the result becomes zero. Also by definition, e raised to the zeroth power is one, which when both definitions are applied leaves us with this:

p = (-0 + \frac{0}{\lambda_2 + \lambda_1}) - (-1 + \frac{\lambda_2}{\lambda_2 + \lambda_1})

Then with some basic mathematical simplification here:

p = 0 - (-1 + \frac{\lambda_2}{\lambda_2 + \lambda_1})

We then end up with our solution of p = 1 - λ2 / (λ2 + λ1):

p = 1 - \frac{\lambda_2}{\lambda_2 + \lambda_1}.

Putting it all together, we get the following:

complete solution to statistical calculus problem

Now that we worked through that, you might be wondering what’s the practical application of this knowledge? Well, one example where you could use it would be in determining the lifespan of two different light bulbs. Given that one light bulb has a rating of 750 hours and the other has a rating of 1500 hours, what is the probability that the one with 1500 hours will last a less amount of time than the one with the 750 hour rating? I’ll leave the answer up to you to solve now that I have explained the steps above, but it must be said, the result is rather surprising.

Tags: , ,

5 Responses to “Solving exponential distribution probability using Calculus”

  1. nikola says:

    nice exposition :) you should maybe mention that the two variables are independent though to avoid confusion and for P(AB) = P(A).P(B) to be applicable..

    Also, another interesting question is – what’s the probability that variable X2 ’survives’ certain x while X1 fails. In this case you will have p = pdfX1 * (1 – CDFX2)

  2. nikola says:

    By the way – here’s a link to some statistical simulation code ( written in R ) dealing with the problem for survival and failure and estimation of Distribution parameters from such data. https://github.com/chochkov/mle_estimation. There’s also Latex and Pdf files in case anyone would be interested..

  3. Erik says:

    What if there are three exponentially distributed parameters? What is the probability that X_1 is less than both X_2 and X_3?

  4. Eric says:

    Jeremy, your derivation is not rigorous. For example, you cannot write P(X_2 = x) since X_2 is a continuous r.v. I am still after a rigorous proof and I cannot find it on the internet. Ross’ popular book abuses notation like you’ve done here.

  5. Bob says:

    surely theres a problem with P(X2=x)=0 regardless of x?

Leave a Comment

Spam Protection by WP-SpamFree