Two mechanics are changing oil filters for the arriving customers. The service time has an Exponential distribution with mean 12 minutes for the first mechanic, and mean 3 minutes for the second mechanic. When you arrive to have your oil filter changed, your probability of being served by the faster mechanic is 0.8. Use simulation to generate 10000 service times and estimate the mean service time for you.
Compare the simulated and the theoretical results. The theoretical mean can be calculated by weighting the two mean times with weights being the probabilities.
SOLUTION:-
Let the service time for first mechanic be and the service time for first mechanic be .
Then
The R code for simulating 10,000 resultent service times and finding the mean is given below.
set.seed(7657)
N <- 10000
X <- array(dim=N)
for(i in 1:N)
{
u <- runif(1)
if(u<0.8)
{
X[i] <- rexp(1,rate=1/3)
}
else
{
X[i] <- rexp(1,rate=1/12)
set.seed(7657)
N <- 10000
X <- array(dim=N)
for(i in 1:N)
{
u <- runif(1)
if(u<0.8)
{
X[i] <- rexp(1,rate=1/3)
}
else
{
X[i] <- rexp(1,rate=1/12)
}
}
mean(X) The mean service time is 4.816
minutes
Please give thumb up...
Thank you in advance....
Get Answers For Free
Most questions answered within 1 hours.