Quiz Study Guide — Appendix B
This deck is a checklist, not a summary. Every slide is phrased as something you should be able to state, derive, or compute without looking it up.
What this appendix is about
Input modeling: turning collected data into the probability distributions that drive a simulation — and testing whether the fit is defensible.
Fitting
Testing
You should be able to:
You should be able to:
| Step | Purpose |
|---|---|
| Document the process | Define the random variable — when the task starts, when it ends, what triggers it |
| Collect data | Develop a sampling plan, run a pilot, then collect |
| Graphical and statistical analysis | Histograms, time-series plots, autocorrelation plots, basic statistics |
| Hypothesize distributions | Propose candidates from physical reasoning plus the analysis |
| Goodness of fit | Estimate parameters, then test via chi-squared, K-S, P-P and Q-Q plots |
A discrete random variable takes values from a specified countable list; a continuous one takes any value in an interval or collection of intervals.
The modeling principle
The decision starts from WHAT is being collected and HOW it is being collected — not from looking at a data file. Values may have decimal places and still be discrete in concept.
This appears as both a multiple-choice item and a true/false item.
\[\bar X(n) = \frac1n \sum_{i=1}^{n} X_i, \qquad S^2(n) = \frac{1}{n-1}\sum_{i=1}^{n}(X_i - \bar X)^2\]
\[c_v = \frac{\sqrt{\mathrm{Var}[X]}}{E[X]}, \qquad \hat c_v = \frac{s}{\bar x}, \qquad \hat\gamma_1 = \frac{(1/n)\sum (X_i - \bar X)^3}{\left[S^2\right]^{3/2}}\]
Median. For \(n\) odd, the \(\left(\frac{n+1}{2}\right)\)th order statistic. For \(n\) even, the average of the \(\frac{n}{2}\)th and \(\left(\frac{n}{2}+1\right)\)th.
Histogram intervals. Square-root rule \(k = \sqrt{n}\); Sturges’ rule \(k = \lfloor 1 + \log_2 n \rfloor\).
Poisson MLE: \(\hat\lambda = \frac1k \sum_{i=1}^{k} n_i\) — the sample average of the interval counts.
Gamma method of moments, with \(E[X] = \alpha\beta\) and \(\mathrm{Var}[X] = \alpha\beta^2\):
\[\hat\alpha = \frac{\bar X^2}{S^2}, \qquad \hat\beta = \frac{S^2}{\bar X}\]
A p-value is the smallest \(\alpha\) level at which the observed test statistic is significant; equivalently, the probability — assuming \(H_0\) true — of observing a test statistic at least as extreme as the one observed.
It is not the probability that \(H_0\) is true.
Decision rule: reject \(H_0\) when p-value \(\leq \alpha\). A small p-value means the observed outcome is rare under \(H_0\), so \(H_0\) is not a plausible explanation. A p-value of 0.001 is strong evidence against \(H_0\).
\[\chi_0^2 = \sum_{j=1}^{k} \frac{(c_j - n p_j)^2}{n p_j}, \qquad \mathrm{df} = k - s - 1, \qquad n p_j \geq 5\]
Computer-lab arrivals example. xtabs(N ~ Week + Period + Day, data = p2) gives a p-value of \(0.7384\), so we do not reject independence; the 160 observations are treated as independent and a Poisson is fit with \(\hat\lambda = 8.275\) per 15-minute interval. After consolidation there are 9 classes with \(s = 1\).
\[D_n = \max(D_n^+, D_n^-), \quad D_n^+ = \max_i\left\{\frac{i}{n} - \hat F(x_{(i)})\right\}, \quad D_n^- = \max_i\left\{\hat F(x_{(i)}) - \frac{i-1}{n}\right\}\]
the largest vertical deviation between the empirical and hypothesized CDFs.
Advantages over chi-squared: more powerful, usable on smaller samples, and independent of the choice of class intervals.
Caveat: when parameters are estimated from the data, the test becomes conservative — the actual Type I error is less than the specified \(\alpha\).
For \(U(0,1)\), \(F(x) = x\), so \(D_n^+ = \max_i\{i/n - x_{(i)}\}\) and \(D_n^- = \max_i\{x_{(i)} - (i-1)/n\}\). For \(n \geq 35\), \(D_{0.05} \approx 1.36/\sqrt{n}\).
\[\tilde F_n(x_{(i)}) = \frac{i}{n}, \qquad \text{continuity correction: } \frac{i-0.5}{n}, \qquad \text{Blom: } \frac{i - 0.375}{n + 0.25}\]
The \(q\)th quantile is \(x_q = F^{-1}(q)\).
P-P plot
\(\tilde F_n(x_{(i)})\) versus \(\hat F(x_{(i)})\) — probability against probability.
Q-Q plot
\(x_{(i)}\) versus \(\hat F^{-1}(q_i)\) with \(q_i = (i-0.5)/n\) — quantile against quantile.
In both, a good fit is an approximately straight line of slope 1 through the origin — a 45-degree line.
Anderson-Darling detects tail differences and has higher power than K-S for many popular distributions; it is standard output in commercial fitting software.
| Test | What it does | df / critical value |
|---|---|---|
| Chi-squared for \(U(0,1)\) | Bin \((0,1)\) into \(k\) equal sub-intervals | \(k - 1\); \(a,b\) known so \(s = 0\) |
| K-S for \(U(0,1)\) | Largest deviation from \(F(x) = x\) | \(1.36/\sqrt{n}\) for \(n \geq 35\) |
| Serial (multi-\(d\)) | Counts in \(k^d\) hypercubes | \(k^d - 1\) |
| Runs up / down | Sequential patterns of “+” and “-” | — |
| Autocorrelation | \(r_k\) versus lag \(k\) | Band \(\pm 1.96/\sqrt{n}\) at 95% |
| Distribution | Typical situation |
|---|---|
| Bernoulli\((p)\) | An independent trial with success probability \(p\) |
| Binomial\((n,p)\) | Sum of \(n\) Bernoulli trials |
| Geometric\((p)\) | Number of Bernoulli trials until the first success |
| Poisson\((\lambda)\) | Counts of occurrences in an interval, area, or volume |
| Discrete uniform | Equally likely over a range or list of values |
| Distribution | Typical situation |
|---|---|
| Uniform | Lack of data; everything equally likely on an interval |
| Exponential | Time to perform a task, time between failures, distance between defects |
| Weibull | Time to failure, time to complete a task |
| Triangular | A rough model given a minimum, a maximum, and a most-likely value |
| Lognormal | Time to perform a task; products of many other quantities |
Exponential signatures. \(c_v = 1\), so \(\hat c_v\) near 1 is consistent with — not proof of — an exponential. And it is memoryless: \(P\{X > \Delta t + t \mid X > t\} = P\{X > \Delta t\}\).
The normal is defined over all the real numbers, including negatives, and “delay for a negative time” causes errors in a discrete-event simulation.
Alternatives: truncated normal, lognormal, gamma, Weibull, exponential.
The lognormal is a convenient task-time model because it is specified by mean and variance and is defined on the positive reals.
fitdistrplus Package| Construct | Role |
|---|---|
plotdist(data, discrete = ...) |
Plots the empirical PMF/CDF (or PDF/CDF) |
fitdist(data, "pois") |
Fits a discrete Poisson by maximum likelihood |
fitdist(data, "gamma") |
Fits a continuous gamma by maximum likelihood |
gofstat(fp) |
Chi-squared, K-S, Cramer-von Mises, Anderson-Darling, AIC, BIC |
plot(fp) |
Empirical versus theoretical density, CDF, P-P, Q-Q |
Gamma task-time example. With \(\bar X = 13.412\) and \(S^2 = 50.44895\), both the chi-squared test (\(p = 0.433\)) and the K-S test (\(p = 0.9444\)) fail to reject the gamma fit, and the P-P and Q-Q plots are approximately linear.