When we studied the Poisson distribution, we computed the discrete probability of observing \(\small{x}\) events per unit time interval as, \(~~~~~\small{P(x,\lambda) = \dfrac{\mu^x e^{-\mu}}{x!}~~~~}\) where \(\small{\lambda}\) is the mean number of events in the same unit interval.
If the number of events occuring in a time interval is a random variable, then the time gap (waiting time) between successive events is also a random variable.. This time gap between events is a continuous variable since the time interval can take any real positive value. We are especially interested in the distribution of the waiting time until the first event occurs in a Poisson process.For example, if on a average we expect to observe 4 events per unit time in a Poisson process, what is the waiting time until we observe the next event?. We will show that this follows an exponential probability density distribution of continuous type.
Let \(\small{\lambda}\) be the mean number of events per unit time interval while observing a Poisson process, and let \(\small{W}\) be the wait time until the first event occurs. We can derive an expression for the probability distribution of the continuous variable \(\small{W}\) as follows:
Let us compute the cumulative probability of observing a waiting time \(\small{W \leq w }\) for the first event:
The probability of getting a waiting time (interval) \(\small{w}\) is given by,
\(\small{P(W \leq w)~=~1 - P(W \geq w) }\)
\(\small{~~~~~~~~~~~~~~~~=~1 - P( no~events~in~the~time~interval~[0,w] )}\)
Since the number of events in unit interval is \(\small{\lambda}\), the probability of no event occuring in a time interval \(\small{w}\) is \(\small{e^{-\lambda w}}\) accoring to Poisson distribution. Therefore we write,
\(~~~~~~~~~~~~\small{ P(W \leq w )~=~1 - e^{-\lambda w} }\)
The cumulative distribution function is obtained by integrating the probability distribution function (pdf). Therefore, we can get the pdf of the distribution of waiting time by differentiating the cumulative function with respect to \(\small{w}\).
\(\small{ P_e(w,\lambda) = \dfrac{d}{dw}(P(W \leq w ) ) = \lambda e^{-w \lambda} }\)
Thus the pdf of waiting time \(\small{w}\) until the first event follows an exponential distribution \( \small{ \lambda e^{-w \lambda}}\), where \(\small{\lambda}\) is the mean number of events occuring in unit time interval.
We define a parameter \(\small{\theta} = \dfrac{1}{\lambda}\) to write the exponential distribution as,
The mean and variance of the exponential distribution are obtained by,
So, if \(\small{\lambda}\) is the mean number of events in unit interval, then \(\small{\theta = \dfrac{1}{\lambda}}\) is the mean waiting time for the first event. Thus if 10 events occur per minute on an average, the mean waiting time unitl the first event is one tenth of a minute.
R provides functions for computing exponential distribution with probability density \(\small{P_e(x) = \dfrac{1}{\theta} {\large e^{-\frac{x}{\theta}}} }\). Here, theta is the inverse of the mean rate in the Poisson distribution.
dexp(x, theta) --------------> returns the uniform probability density for a given x value pexp(x, theta) --------------> returns the cumulative probability from 0 upto x qexp(p, theta) ---------------> returns the x value at which the cumulative probability is p rexp(n, theta) ---------------> returns n random numbers in the range [0 , infinity] from an exponential distribution with the given theta parameter. The R script below demonstrates the usage of the above mentioned functions:
##### Using R library functions for Poisson distribution yx = dexp(3, 0.5) yx = round(yx, digits=4) print(paste("Probability density at x=3 for beta = 1/2 is : ", yx)) px = pexp(3,0.5) px = round(yx, digits=4) print(paste("Cumulative probability upto x=3 for beta = 1/2 is : ", px)) qx = qexp(.935, 0.5) qx = round(qx, digits=4) print(paste("Value of x upto which cumulative probability is 0.35, for theta = 1/2 is : ", qx)) rx = rexp(4, 0.5) rx = round(rx, digits=4) print(paste("Four random deviates from exponential distribution with theta = 1/2 : ")) print(rx)
Executing the above code prints the following lines on the screen:
[1] "Probability density at x=3 for beta = 1/2 is : 0.1116" [1] "Cumulative probability upto x=3 for beta = 1/2 is : 0.1116" [1] "Value of x upto which cumulative probability is 0.35, for theta = 1/2 is : 5.4667" [1] "Four random deviaites from exponential distribution with theta = 1/2 : " [1] 0.0360 1.4116 2.3654 1.9593