Activity: Distribution Fitting

Modeling Randomness Activities

Author

Manuel D. Rossetti, PhD P.E.

We write this program together: the instructor types the code, and you type along. Before each step, write down a prediction; then run and check it.

The question. The file movieTheaterData.txt holds 250 times, in seconds, to serve a customer at a movie theater counter. Recommend a distribution to model them in a simulation, following the steps of the book’s appendix on probability distribution modeling:

  1. Look at the data, graphically and with statistics.
  2. Hypothesize distributions.
  3. Estimate their parameters.
  4. Check the goodness of fit.

Setup. Get the starter file MovieTheaterFitting.kt from the code/ folder beside this activity, and the data file movieTheaterData.txt from the data/ folder. Put the starter in src/main/kotlin/student/activities in your KSL project, the package the file declares; create the folder if you do not have it. The first lines of main give the path to the data file: change it to where you saved the file. Run main: it shows the data, but the two functions marked TODO are what we write.

1. Look at the data

  1. Before you look, sketch the shape you expect for service times at a counter.

  2. Run. Describe the histogram. Is any one of the usual distributions likely to fit it?

  3. Look at the observation plot and the ACF plot. Are the observations independent and from one stable process? Why must we check before fitting?

  4. The sample mean is 64.4 and the sample standard deviation is 30.0. What do the statistics alone miss that the histogram shows?

2. Fit all the data

We write fitAndReport (TODO 1) together.

  1. Predict whether any distribution will pass the goodness-of-fit tests.

  2. Run. Which distribution is ranked first? Do the tests reject it?

3. Split the data

The histogram suggests two kinds of customers. We write splitAnalysis (TODO 2) together: it splits the data at 80 seconds and fits each part.

  1. Why might there be two kinds of customers at a movie theater counter?

  2. Run. What does the PDFModeler recommend for each part? Do the tests reject them?

  3. The PDFModeler shifted one part but not the other. What does the shift mean?

  4. Write the recommended model as a mixture: with what probability does a customer come from each part?

  5. Change the split to 75, then to 70. Does the recommendation change? How would you choose the split point?

4. Recommend

  1. Write your recommendation for the simulation, and how you would generate a service time from it.

  2. What would go wrong if the simulation used the single distribution from part 2?