{"id":34,"date":"2011-08-25T11:57:30","date_gmt":"2011-08-25T11:57:30","guid":{"rendered":"http:\/\/www.clayford.net\/statistics\/?p=34"},"modified":"2023-08-16T06:53:40","modified_gmt":"2023-08-16T10:53:40","slug":"deriving-the-exponential-distribution","status":"publish","type":"post","link":"https:\/\/www.clayford.net\/statistics\/deriving-the-exponential-distribution\/","title":{"rendered":"Deriving the exponential distribution"},"content":{"rendered":"<p>The exponential distribution looks harmless enough:<\/p>\n<p>$$ f(x) = \\frac{1}{\\theta}e^{-x\/\\theta}$$<\/p>\n<p>It looks like someone just took the exponential function and multiplied it by \\( \\frac{1}{\\theta}\\), and then for kicks decided to do the same thing in the exponent except with a negative sign. If we integrate this for all \\( x&gt;0 \\) we get 1, demonstrating it&#8217;s a probability distribution function. So is this just a curiosity someone dreamed up in an ivory tower? No it actually turns out to be related to the Poisson distribution.<\/p>\n<p>Recall the Poisson describes the distribution of probability associated with a Poisson process. That is, the number of events occurring over time or on some object in non-overlapping intervals are independent. For example, maybe the number of 911 phone calls for a particular city arrive at a rate of 3 per hour. The interval of 7 pm to 8 pm is independent of 8 pm to 9 pm. The expected number of calls for each hour is 3. The Poisson distribution allows us to find, say, the probability the city&#8217;s 911 number receives more than 5 calls in the next hour, or the probability they receive no calls in the next 2 hours. It deals with discrete counts.<\/p>\n<p>Now what if we turn it around and ask instead how long until the next call comes in? Now we&#8217;re dealing with time, which is continuous as opposed to discrete. We&#8217;re limited only by the precision of our watch. Let&#8217;s be more specific and investigate the time until the <em>first change<\/em> in a Poisson process. Before diving into math, we can develop some intuition for the answer. If events in a process occur at a rate of 3 per hour, we would probably expect to wait about 20 minutes for the first event. Three per hour implies once every 20 minutes. But what is the probability the <em>first<\/em> event within 20 minutes? What about within 5 minutes? How about after 30 minutes? (Notice I&#8217;m saying <em>within<\/em> and <em>after<\/em> instead of <em>at<\/em>. When finding probabilities of continuous events we deal with intervals instead of specific points. The probability of an event occurring at a specific point in a continuous distribution is always 0.)<\/p>\n<p>Let&#8217;s create a random variable called W, which stands for wait time until the <em>first<\/em> event. The probability the wait time is less than or equal to some particular time <em>w<\/em> is \\( P(W \\le w)\\). Let&#8217;s say <em>w<\/em>=5 minutes, so we have \\( P(W \\le 5)\\). We can take the complement of this probability and subtract it from 1 to get an equivalent expression:<\/p>\n<p>$$ P(W \\le 5) = 1 &#8211; P(W&gt;5)$$<\/p>\n<p>Now \\( P(W&gt;5)\\) implies no events occurred before 5 minutes. That is, nothing happened in the interval [0, 5]. What is the probability that nothing happened in that interval? Well now we&#8217;re dealing with events again instead of time. And for that we can use the Poisson:<\/p>\n<p>Probability of no events in interval [0, 5] = \\( P(X=0) = \\frac{\\lambda^{0}e^{-\\lambda}}{0!}=e^{-\\lambda}\\)<\/p>\n<p>So we have \\( P(W \\le 5) = 1 &#8211; P(W&gt;5) = 1 &#8211; e^{-\\lambda}\\)<\/p>\n<p>That&#8217;s the cumulative distribution function. If we take the derivative of the cumulative distribution function, we get the probability distribution function:<\/p>\n<p>$$ F'(w)=f(w)=\\lambda e^{-\\lambda}$$<\/p>\n<p>And there we have the exponential distribution! Usually we let \\( \\lambda = \\frac{1}{\\theta}\\). And that gives us what I showed in the beginning:<\/p>\n<p>$$ f(x) = \\frac{1}{\\theta}e^{-x\/\\theta}$$<\/p>\n<p>Why do we do that? That allows us to have a parameter in the distribution that represents the mean waiting time until the first change. Recall my previous example: if events in a process occur at a mean rate of 3 per hour, or 3 per 60 minutes, we expect to wait 20 minutes for the first event to occur. In symbols, if \\( \\lambda\\) is the mean number of events, then \\( \\theta=\\frac{1}{\\lambda}\\), the mean waiting time for the first event. So if \\( \\lambda=3\\) is the mean number of events per hour, then the mean waiting time for the first event is \\( \\theta=\\frac{1}{3}\\) of an hour. Notice that \\( \\lambda=3=\\frac{1}{1\/3}=\\frac{1}{\\theta}\\).<\/p>\n<p>Tying everything together, if we have a Poisson process where events occur at, say, 12 per hour (or 1 every 5 minutes) then the probability that <em>exactly<\/em> 1 event occurs during the next 5 minutes is found using the Poisson distribution (with \\( \\lambda=\\frac{1}{5}\\)):<\/p>\n<p>$$ P(X=1) = \\frac{(1\/5)^{1}e^{-(1\/5)}}{1!}=0.164$$<\/p>\n<p>But the probability that we wait less than <em>some time<\/em> for the <em>first event<\/em>, say 5 minutes, is found using the exponential distribution (with \\( \\theta = \\frac{1}{1\/5} = 5\\)):<\/p>\n<p>$$ P(X&lt;5)=\\int_{0}^{5}\\frac{1}{5}e^{-x\/5}dx=1-e^{-5\/5}=1-e^{-1}=0.632$$<\/p>\n<p>Now it may seem we have a contradiction here. We have a 63% of witnessing the first event within 5 minutes, but only a 16% chance of witnessing one event in the next 5 minutes. While the two statements seem identical, they&#8217;re actually assessing two very different things. The Poisson probability is the chance we observe exactly one event in the next 5 minutes. Not 2 events, Not 0, Not 3, etc. Just 1. That&#8217;s a fairly restrictive question. We&#8217;re talking about one outcome out of many. The exponential probability, on the other hand, is the chance we wait less than 5 minutes to see the first event. This is <em>inclusive<\/em> of all times before 5 minutes, such as 2 minutes, 3 minutes, 4 minutes and 15 seconds, etc. There are many times considered in this calculation. So we&#8217;re likely to witness the first event within 5 minutes with a better than even chance, but there&#8217;s only a 16% chance that all we witness in that 5 minute span is exactly one event. The latter probability of 16% is similar to the idea that you&#8217;re likely to get 5 heads if you toss a fair coin 10 times. That is indeed the most likely outcome, but that outcome only has about a 25% chance of happening. Not impossible, but not exactly what I would call probable. Again it has to do with considering only 1 outcome out of many. The Poisson probability in our question above considered one outcome while the exponential probability considered the infinity of outcomes between 0 and 5 minutes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The exponential distribution looks harmless enough: $$ f(x) = \\frac{1}{\\theta}e^{-x\/\\theta}$$ It looks like someone just took the exponential function and&#8230; <a class=\"read-more\" href=\"https:\/\/www.clayford.net\/statistics\/deriving-the-exponential-distribution\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-34","post","type-post","status-publish","format-standard","hentry","category-continuous-distributions"],"_links":{"self":[{"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/posts\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/comments?post=34"}],"version-history":[{"count":3,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/posts\/34\/revisions"}],"predecessor-version":[{"id":854,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/posts\/34\/revisions\/854"}],"wp:attachment":[{"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/media?parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/categories?post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/tags?post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}