Suppose that there exists two mechanics who perform oil changes. The times it takes for each mechanic to complete the oil change both follow exponential distributions, with the first mechanic having a mean service time of 3 minutes and the second having a mean service time of 12 minutes. For any given customer, they have an 80% chance of being served by the faster mechanic and a 20% chance of being served by the slower. We are asked to find the mean service time of all customers getting oil changes using simulations via R, and to compare this to the theoretical mean service time.
In creating the simulation, we will be using 10,000 trials to very closely approximate the true mean oil change time. Here are 50 possible sample values:
## [1] 2.80654185 2.97368223 0.26138837 13.41639484 6.82237068 11.57743569
## [7] 0.78742121 6.74199119 1.30346734 5.61774300 1.93619126 4.04490518
## [13] 3.00851350 4.12936643 3.46665858 2.27055393 1.50879619 3.02913671
## [19] 4.21603684 10.04975989 3.01106396 1.12975997 4.92870661 7.20210359
## [25] 5.89203647 0.23580571 0.16918321 5.68575078 10.98087693 2.38747224
## [31] 26.03613220 9.15153780 1.75157292 0.29489719 2.25793441 1.82756745
## [37] 6.42691461 7.07578241 2.41906886 2.94403882 0.23447013 4.59718510
## [43] 0.04211809 6.55128600 2.25664708 1.50229495 3.19274140 0.81392848
## [49] 6.22694222 5.33079238
As can be seen, most values appear to lie somewhere in the 2 to 8 range with a few outliers. The totality of the trials is best represented by histograms.
Here are the 10,000 trials represented by histograms. In the first histogram, we can see the data mostly closely align with the trend of the theoretical distribution derived from the equation in the paper (that is, to add together the two exponential distributions multiplied by their associated weights). This will typically be the case when working with a very large number of trials, such as 10,000 oil changes.
In the second histogram, we can also see a slight distinction between the theoretical mean servicing time and the observed mean servicing time. Specifically, with the current set seed, the observed mean is about 4.713 minutes, while the theoretical mean is exactly 4.8 minutes, for a difference of about 0.9 minutes.
We calculate this theoretical mean by adding together each of the constituent distributions’ means multiplied by their weights.
3(0.8) + 12(0.2) = 4.8