Transcription
Welcome back. Okay, we've been talking about the expectation value and variance of a random variable X, and this conversation has gotten pretty, uh, kind of theoretical. We've done a bunch of math derivations, given a lot of properties, haven't done a lot of actual calculations. So today, I want to do a simple example on a very common distribution that you'll see all the time: the exponential distribution.
So let's say that we have some random variable, uh, T, and let's say that it is exponentially distributed. Exponential. And remember, the exponential distribution has this, uh, Lambda parameter, the hazard rate. So this, um, is the distribution for the waiting times between kind of Poisson random events, like getting an email or a phone call or a light bulb failure. Okay, pretty nice, common distribution. And the probability density function for this distribution, uh, f of little T is equal to, uh, Lambda e to the minus Lambda T. Really, really nice, well-behaved, smooth distribution parameterized by a single number, Lambda.
Um, and so what we're going to do now is we are going to show how to actually compute from scratch the expectation value of X—of I guess of T—um, and the variance of T. So whatever my random variable it is, it doesn't matter if I call this T or X or Y. I could call my random variable Steve if I liked. Um, it doesn't matter. Okay, this is a random variable, and it has a distribution, and we're going to compute its expectation value and its variance. Uh, let's get started. Okay, I'll draw a teeny little picture here. The probability density is an exponential function. Okay, that's what F of T looks like. Good.
Uh, so let's just jump right in. The mean, uh, the average is this expectation value, and the expectation value is defined as the weighted sum of all of the values of T times their probability of occurring. And so for a continuous, uh, random variable like T, an exponential variable, this is equal to the integral from 0 to Infinity. Normally this would be the integral from negative Infinity to Infinity, but this is only defined for positive, uh, non-negative T; T is greater than or equal to zero. It's the—the expectation is defined as T, the integral from 0 to Infinity of T * F of T, T times the distribution F of T, dT.
Um, that equals integral 0 to Infinity of T Lambda e to the minus Lambda T dT. Um, this is not trivial to integrate. Um, it's not like one of the ones that you know just off the top of your head, but it's pretty easy to integrate using, uh, integration by parts. So essentially, um, let's see what colors I want to use here. Maybe I'll do orange. We're basically going to say that, uh, U equals T and DV equals e to the minus Lambda T. And so, uh, dU equals dT and DV equals—we're going to say V as minus e to the minus Lambda T. So dV equals minus—minus is plus Lambda e to the minus Lambda T. And so this is essentially UV—UV—there's a dT here—this is uh, this is U, this is dV. And so we're going to use integration by parts; that is UV evaluated at the bounds of integration minus the integral of V * dU.
Okay, so this equals, uh, U * V evaluated at the bounds of integration. U * V, so that is minus T e to the minus Lambda T evaluated at Infinity and zero minus the integral of V dU. So that's minus the integral from 0 to Infinity of V dU, which is minus—this is minus minus is going to be a plus—e to the minus Lambda T dT. V dU. And this is easy to integrate, right? This is just an exponential. This is like first-year, uh, differential equations; we know how to do this. And this guy is also pretty easy. E to the minus Lambda T evaluated at Infinity, even though I have this T out here, this decay is faster, so the first bound is zero. And if I plug in zero here, e to the 0 is 1, and minus T is zero, so both bounds of integration here are zero. This equals 0 plus a -1/Lambda e to the minus Lambda T, uh, again evaluated from 0 to Infinity. Um, at Infinity this is equal to zero; e to the minus Infinity is zero. And at zero this is one, and so this just equals—and it's this evaluated at Infinity minus this evaluated at zero, so it's minus minus is a +1 over Lambda.
Okay, so the mechanics are pretty easy. You're going to be using your Calculus; you're going to be using your integration by parts or your substitution factors or, you know, whatever it is, but computing this expectation value is a relatively straightforward procedure. You just go through the motions of writing down this integral, um, this first moment integral, plugging in the PDF, and doing some, you know, relatively simple, uh, calculus to get to this expectation value. Okay, good. Um, and you can do the same thing for the mean, uh, sorry for the variance and the standard deviation. So I'm just going to write those down here. Uh, so if I have the variance, uh, remember, um, the variance is VAR(T) is going to be, um, equal to the expectation of T squared minus the expected value of T squared. This is the expected value of T, so I can just plug in 1 over Lambda squared here, but now I have to compute this expectation of T squared. So expectation of T squared, um, expectation of T squared is equal to the integral from 0 to Infinity of—now I'm just going to plug in T squared here. Remember there's this property: the expectation of G of T, uh, is the integral over the bounds of integration of G of T F of T dT. So I literally just take this, uh, this T here and I replace it with the function I'm computing the expectation value of. So if my function is T squared, I just replace T here with a T squared. Okay, so this becomes a little T squared, uh, Lambda e to the minus Lambda T dT. And I'm going to let you work out the kind of gory details here. Equals dot dot dot equals, and this guy, uh, expectation of T squared is going to be 2 over Lambda squared. Okay, so this term is 2 over Lambda squared; this term is 1 over Lambda squared, so minus 1 over Lambda squared, and so my variance of this exponentially distributed random variable is just 1 over Lambda squared. Pretty nice. And of course that means, uh, I'm just going to start writing these: so the expectation of T equals 1 over Lambda; VAR(T) = 1/Lambda squared; that means the standard deviation of T is the square root of this, equals 1/Lambda. That's pretty interesting; the standard deviation is equal to the mean.
Okay, so the—the mean value and the standard deviation are equal to each other. So I want you to think about if that makes sense. Is that what you expected? Is that weird? Is that partly responsible to this memory—memoryless effect of this distribution? I want you to think about, you know, does this make sense. Um, good. And maybe one last question—quantity that I think is actually quite important for you—um, is the median. Okay, so the median value, which is a robust, um, kind of neighbor or cousin of the expected value, the median of this distribution, the median of T is the value of little t such that half of the distribution, one-half of the weight of the distribution is on the left and one-half of the probability of the distribution is on the right. Okay, this would be the median. And the way you would find the median is you would find the cumulative density function of F, and you'd find the point where half of that cumulative density is to the left and half is to the right. So you'd find the cumulative density, the little T where the cumulative density equals one-half.
Okay, so let's just write that out. Um, F of T, um, the cumulative density is the integral from 0 to t, uh, of this dT. That's equal to the cumulative density, and I think this was one of my homework problems earlier, but I'll just write it down. The cumulative density, given this guy, really easy to integrate. I think it's 1 minus e to the minus Lambda T. Um, yep, that's right. And the median T is the value where F of t equals one-half. So I'm trying to find the value of T that makes this equal to one-half. So if this equals one-half, I can subtract one from both sides; that's negative one-half; divide by negative; so now I have e to the minus Lambda T equals one-half. And so I do log, divide by Lambda, and I get T equals log of 2 divided by Lambda. That is the value of T at which my cumulative distribution equals one-half, meaning it's my median T. So my median value is log of two, natural log of two, divided by Lambda. So it's interesting; it's slightly different; it's my mean times log of two; it's a little bit shifted as the median. Okay. And that's also kind of an interesting value. So I just want you to get comfortable. These are not super complicated to compute. Sometimes you use a little calculus. Um, sometimes I omit steps and let you do this, um, but these are easily computable for normal distributions, exponential distributions; some of them are a little harder than others. Um, pretty easy for Poisson. So that's a good homework problem: is to go through all of this math for the Poisson distribution to find the expected value, the variance, the standard deviation, uh, and the median, and just, you know, be comfortable that you can actually compute these things and understand and analyze them. Okay, thank you.