Description of Problem

A car maintenance company employs two mechanics who change oil filters all day. The first mechanic ‘Myrtle the Turtle’ is able to service 1 customer an average of every 12 minutes, and has a 20% chance of servicing your car. The second mechanic ‘Fast Eddy’ can service a customer an average of every 3 minutes, and there’s an 80% chance he will service your car. On average, how long should you expect it to take to have your car serviced?

Solution:

Let the service time for the first mechanic be X_1 and the service time for first mechanic be X_2. Then X_1 is given by Exp(1/12), and X_2 given by Exp(1/3) The resulting service time is X_2 with probability 0.8 and X_1 with probability 0.2

Here are some of the simulated wait times:

##  [1]  0.1378883 18.4890600  1.4370768  0.2645904  2.1078414  0.4465948
##  [7]  4.2944628  2.8650284  0.9246410 12.3166782  5.1362093 24.0876863
## [13]  4.5423123 22.9593677  1.5745901 10.8418453  0.3169107  0.6082041
## [19]  2.0553462  3.2847143  6.0782269  1.0117557  1.1993950  1.1470831

Summary Plot

Below is a summary of results with a histogram of the simulated data, with two vertical lines representing the simulated mean and the theoretical mean. The resulting values for mean values are included below the histogram.

##                 Mean     Theoretical Mean 
##             4.815798             4.800000

Discussion:

The results of this simulation show that the mean for the simulated results approaches that of theory as the number of trials increases, highlighting the benefit of large data sets to have a result that is predicted by theory.

Code:

The R code for simulating 10000 resultant service times X and finding the mean is given below.

set.seed(7657)
i<-1
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)
  }
  }
Theoretical_Mean = 0.2*12+0.8*3
hist(X, probability = TRUE, xlim = c(0,10), ylim=c(0,.16))
abline(v = mean(X))
abline(v = Theoretical_Mean)
Theoretical_Mean = 0.2*12+0.8*3
Simulated_Mean = mean(X)