引言
指數分布描述了隨機再次發生的獨立事件序列的到達時間。如果μ是未來一個新獨立事件發生的平均等待時間,它的概率密度函數是:
下圖是 μ = 1時的指數分布的概率曲線
R實踐
Density, distribution function, quantile function and random generation for the exponential distribution with rate rate
(i.e., mean 1/rate
).
這里的rate 就是公式中的 1/μ,就是速率rate 等於1除以平均等待時間.
# dexp gives the density
dexp(x, rate = 1, log = FALSE)
# pexp gives the distribution function
pexp(q, rate = 1, lower.tail = TRUE, log.p = FALSE)
# qexp gives the quantile function
qexp(p, rate = 1, lower.tail = TRUE, log.p = FALSE)
# rexp generates random deviates for the exponential distribution
rexp(n, rate = 1)
如果 rate
沒有指定,則取默認值為 1
.
Problem
假設超市收銀員的平均結賬時間是3分鍾。計算收銀員在兩分鍾內完成某個顧客的結賬的概率。
Solution
結帳處理速度等於1除以平均結帳完成時間。因此,結帳處理速度是 每分鍾1/3。然后我們應用指數分布的pexp函數,其速率為1/3。
Answer
> pexp(q = 2, rate = 1/3)
[1] 0.487