<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ramblings of a Geek - Jeremy Johnstone &#187; calculus</title>
	<atom:link href="http://www.jeremyjohnstone.com/tag/calculus/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jeremyjohnstone.com</link>
	<description>Ramblings of a Geek</description>
	<lastBuildDate>Sat, 04 Feb 2012 18:33:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Solving exponential distribution probability using Calculus</title>
		<link>http://www.jeremyjohnstone.com/blog/2010-02-01-solving-exponential-distribution-probability-using-calculus.html</link>
		<comments>http://www.jeremyjohnstone.com/blog/2010-02-01-solving-exponential-distribution-probability-using-calculus.html#comments</comments>
		<pubDate>Mon, 01 Feb 2010 07:28:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[calculus]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://www.jeremyjohnstone.com/?p=1542</guid>
		<description><![CDATA[Today I was challenged with the following advanced statistics problem:
Two variables are exponentially distributed with rate parameters lambda 1 (&#160;&#955;1&#160;) and lambda 2 (&#160;&#955;2&#160;). What is the probability (&#160;p&#160;) that variable 1 (&#160;X1&#160;) is less than variable 2 (&#160;X2&#160;) in terms of lambdas?
Being one who is usually up to a good challenge, this sounded like [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was challenged with the following advanced statistics problem:</p>
<blockquote><p>Two variables are exponentially distributed with rate parameters lambda 1 (&nbsp;&#955;<sub>1</sub>&nbsp;) and lambda 2 (&nbsp;&#955;<sub>2</sub>&nbsp;). What is the probability (&nbsp;p&nbsp;) that variable 1 (&nbsp;X<sub>1</sub>&nbsp;) is less than variable 2 (&nbsp;X<sub>2</sub>&nbsp;) in terms of lambdas?</p></blockquote>
<p>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. </p>
<p>Let&#8217;s start off with some definitions. First off, we need to brush up a little bit on <a href="http://en.wikipedia.org/wiki/Exponential_distribution">exponential distribution</a> and we then can see that to get the probability that X<sub>1</sub>&nbsp;&lt;&nbsp;X<sub>2</sub> for all possible legal values from zero to infinity, we use the following problem definition:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/definition.png" alt="p = \int^\infty_0 P(X_2=x)P(X_1<x) dx" /></center></p>
<p>What it&#8217;s essentially saying is that the probability that X<sub>1</sub>&nbsp;&lt;&nbsp;X<sub>2</sub> is the combined probability that X<sub>2</sub>&nbsp;=&nbsp;x AND X<sub>1</sub>&nbsp;&lt;&nbsp;x. From there, we can do some simple replacements. To find the probability that X<sub>2</sub>&nbsp;=&nbsp;x we use the <a href="http://en.wikipedia.org/wiki/Probability_density_function">Probability density function</a> (PDF). Then to find the probability that X<sub>1</sub>&nbsp;&lt;&nbsp;x we use the <a href="http://en.wikipedia.org/wiki/Cumulative_distribution_function">Cumulative distribution function</a> (CDF). Based on the definition that P(A and B) is the same as P(A)P(B), we end up with:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/step1.png" title="p = \int^\infty_0 PDF_{X_2}(x) CDF_{X_1}(x) dx" alt="p = \int^\infty_0 PDF_{X_2}(x) CDF_{X_1}(x) dx"/></center></p>
<p>Next up, we need to do some substitutions for PDF and CDF respectively. According to Wikipedia, PDF is defined as:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/PDF.png" alt="definition of probability density function (PDF)" title="definition of probability density function (PDF)" /></center></p>
<p>And CDF is defined as:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/CDF.png" alt="definition of cumulative distribution function (CDF)" title="definition of cumulative distribution function (CDF)"/></center></p>
<p>So with that in mind, we now arrive at this:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/step2.png" alt="p = \int^\infty_0 \lambda_2 e^{-\lambda_2 x}(1-e^{-\lambda_1 x}) dx" title="p = \int^\infty_0 \lambda_2 e^{-\lambda_2 x}(1-e^{-\lambda_1 x}) dx" /></center></p>
<p>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>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/step3.png" alt="p = \int^\infty_0 \lambda_2 e^{-\lambda_2 x} dx - \lambda_2 e^{-\lambda_2 x} \lambda_2 e^{-\lambda_1 x} dx" title="p = \int^\infty_0 \lambda_2 e^{-\lambda_2 x} dx - \lambda_2 e^{-\lambda_2 x} \lambda_2 e^{-\lambda_1 x} dx" /></center></p>
<p>After that, we will use exponential identities to refactor the problem down a bit further to this:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/step4.png" alt="p = \int^\infty_0 \lambda_2  e^{-\lambda_2 x} dx - \lambda_2 e^{-\lambda_2 x - \lambda_1 x} dx" title="p = \int^\infty_0 \lambda_2  e^{-\lambda_2 x} dx - \lambda_2 e^{-\lambda_2 x - \lambda_1 x} dx" /></center></p>
<p>At this point, we can now proceed to solve the integral and using the definition that the integration of e^x&nbsp;=&nbsp;e^x and subsequently e^-x&nbsp;=&nbsp;-e^-x we end up with the following:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/step5.png" alt="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" title="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" /></center></p>
<p>After then doing some basic simplification of the fractions, we now end up with this:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/step6.png" alt="p = (-e^{-\lambda_2 x} + \frac{\lambda_2 e^{-\lambda_2 x - \lambda_1 x}}{\lambda_2 + \lambda_1})\Big |^\infty_0" title="p =(-e^{-\lambda_2 x} + \frac{\lambda_2 e^{-\lambda_2 x - \lambda_1 x}}{\lambda_2 + \lambda_1})\Big |^\infty_0" /></center></p>
<p>Next up, we need to apply the closed interval to the function using the <a href="http://">fundamental theorem of calculus</a>. The fundamental theorem states that when integrating f(x) over the interval [a,b] the result is F(b) &#8211; F(a) as seen here in this definition:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/fundamental_calc_theorem.png" alt="integrating f(x) over the interval [a,b] the result is F(b) - F(a)" title="integrating f(x) over the interval [a,b] the result is F(b) - F(a)" /></center></p>
<p>When we apply the fundamental theorem to our equation it gives us this result:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/step7.png" alt="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})" title="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})" /></center></p>
<p>Next up, we now need to calculate the results of the <a href="http://en.wikipedia.org/wiki/Exponential_function">exponential functions</a>. 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>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/step8.png" alt="p = (-0 + \frac{0}{\lambda_2 + \lambda_1}) - (-1 + \frac{\lambda_2}{\lambda_2 + \lambda_1})" title="p = (-0 + \frac{0}{\lambda_2 + \lambda_1}) - (-1 + \frac{\lambda_2}{\lambda_2 + \lambda_1})" /></center></p>
<p>Then with some basic mathematical simplification here:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/step9.png" alt="p = 0 - (-1 + \frac{\lambda_2}{\lambda_2 + \lambda_1})" title="p = (0 - (-1 + \frac{\lambda_2}{\lambda_2 + \lambda_1})" /></center></p>
<p>We then end up with our solution of p&nbsp;=&nbsp;1&nbsp;-&nbsp;&#955;<sub>2</sub>&nbsp;/&nbsp;(&#955;<sub>2</sub>&nbsp;+&nbsp;&#955;<sub>1</sub>):</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/step10.png" alt="p = 1 - \frac{\lambda_2}{\lambda_2 + \lambda_1}." title="p = 1 - \frac{\lambda_2}{\lambda_2 + \lambda_1}." /></center></p>
<p>Putting it all together, we get the following:</p>
<p><center><img src="http://www.jeremyjohnstone.com/wordpress/wp-content/uploads/2010/01/final_solution.png" alt="complete solution to statistical calculus problem" title="complete solution to statistical calculus problem" /></center></p>
<p>Now that we worked through that, you might be wondering what&#8217;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&#8217;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.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeremyjohnstone.com/blog/2010-02-01-solving-exponential-distribution-probability-using-calculus.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

