Exercise 9
Assume that the service time for a customer at a bank is
exponentially distributed with mean service time 2 minutes. Let X be the
total service time for 10 customers. Estimate the probability that X
> 22 minutes.
#Step 1: Defining Parameters
rate <- 1/2 # rate parameter (λ) of the exponential distribution
#Step 2: Calculating Gamma Distribution
alpha <- 10 # shape parameter (number of customers)
beta <- 1/(2 * rate) # scale parameter (β) of the gamma distribution
#Step 3: Computing Probability
prob_X_gt_22 <- 1 - pgamma(22, shape = alpha, rate = beta)
#Output the result
print(paste("Probability that X > 22 minutes:", prob_X_gt_22))
## [1] "Probability that X > 22 minutes: 0.00150493218583958"
Explanation:
In Step 1, we define the rate parameter for the exponential
distribution based on the mean service time.
In Step 2, we calculate the shape (α) and scale (β) parameters of the
gamma distribution using the formula: α = 10 (number of customers) and β
= 1/(2 * rate).
In Step 3, we use the pgamma() function to calculate the cumulative
distribution function (CDF) of the gamma distribution at 22 minutes.
Then, we subtract this value from 1 to get the probability that the
total service time for 10 customers exceeds 22 minutes.
Finally, we print the result.
LS0tDQp0aXRsZTogIkRpc2N1c3Npb24gOCINCmF1dGhvcjogIkxhdXJhIFAiDQpkYXRlOiAiYHIgU3lzLkRhdGUoKWAiDQpvdXRwdXQ6IG9wZW5pbnRybzo6bGFiX3JlcG9ydA0KLS0tDQoNCg0KDQojIyMgRXhlcmNpc2UgOQ0KDQpBc3N1bWUgdGhhdCB0aGUgc2VydmljZSB0aW1lIGZvciBhIGN1c3RvbWVyIGF0IGEgYmFuayBpcyBleHBvbmVudGlhbGx5IGRpc3RyaWJ1dGVkIHdpdGggbWVhbiBzZXJ2aWNlIHRpbWUgMiBtaW51dGVzLiBMZXQgWCBiZSB0aGUgdG90YWwgc2VydmljZSB0aW1lIGZvciAxMCBjdXN0b21lcnMuIEVzdGltYXRlIHRoZSBwcm9iYWJpbGl0eSB0aGF0IFggPiAyMiBtaW51dGVzLg0KDQpgYGB7cn0NCiNTdGVwIDE6IERlZmluaW5nIFBhcmFtZXRlcnMNCnJhdGUgPC0gMS8yICAj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