5. Selecting Input Probability Distributions

How to choose the input distributions a simulation feeds on: assess sample independence, hypothesize a distribution family, estimate its parameters by maximum likelihood, and judge the fit with chi-square and K-S tests.

flowchart LR
    RNG[RNG] -->|"U(0,1)"| T[transformations]
    F(["f / F (input distribution)"]) --> T
    T -->|RVs| P((simulation program))

Chapter 3 built the RNG and Chapter 4 the transformations. This chapter is about the remaining box: which input distribution ff / FF to use.

E.g. for the M/M/1M/M/1 queue we simply assumed exponential interarrival and service times. Q:

  1. How to select input distributions?
  2. Is a specified input distribution a good approximation of the actual process?
flowchart LR
    D[Data] --> I[input distributions]

In practice, an input distribution is specified based on data collected from the actual process by observing an input r.v. of interest.

Three approaches

  1. Use the actual data directly (e.g. customer service times): store the data in a “lookup” table and read the values in order during the simulation (trace-driven simulation).
    1. Disadvantage: this approach is very expensive and time-consuming (a large amount of data must be stored and read).
    2. Disadvantage: it can only reproduce what has happened historically.
    3. Use case: typically used in failure analysis, and to validate a model of an existing system (feed the model the same historical inputs and compare its output with the real system’s).
  2. Use the data to fit an empirical distribution (frequency distribution, histogram), and then sample from the empirical distribution during the simulation.
    1. Disadvantage: it is not possible to generate values outside the range of the observed data X1,…,XnX_1, \dots, X_n, i.e. outside [min⁡iXi, max⁡iXi]\left[\min_i X_i,\ \max_i X_i\right].
  3. Use the data to fit a theoretical distribution (a parameterized distribution such as Exp(λ)\text{Exp}(\lambda), N(μ,σ2)N(\mu, \sigma^2), U(a,b)U(a, b)); use statistical methods to determine the quality of fit.
    1. Advantage: compact representation of the data (a few parameters instead of nn numbers).
    2. Advantage: flexible → “what-if” questions (e.g. what if service becomes 10% faster? Just change a parameter).
    3. Advantage: it can generate values outside the observed range, and it smooths out the irregularities of a small sample.

Use the third approach whenever possible, i.e. whenever some theoretical distribution fits the data well.

Assumption: to fit a distribution, the data should be i.i.d. observations, i.e. X1,X2,…,XnX_1, X_2, \dots, X_n are i.i.d. from an underlying distribution. (§5.1 checks the independence part.)

5.1. Techniques for assessing sample independence

Given X1,X2,…,XnX_1, X_2, \dots, X_n, in the order they were observed.

  • Correlation plot

The correlation between two observations jj apart (lag jj) is

ρj=corr⁡(Xi,Xi+j)=cov⁡(Xi,Xi+j)Var⁡(Xi) Var⁡(Xi+j).\rho_j = \operatorname{corr}(X_i, X_{i+j}) = \frac{\operatorname{cov}(X_i, X_{i+j})}{\sqrt{\operatorname{Var}(X_i)}\,\sqrt{\operatorname{Var}(X_{i+j})}} .

If ρj≠0\rho_j \ne 0 for some jj, then the XiX_i’s are not independent.

From the data, estimate ρj\rho_j by

ρ^j=C^jS2(n),C^j=1n−j∑i=1n−j(Xi−Xˉ(n))(Xi+j−Xˉ(n)),\hat\rho_j = \frac{\hat C_j}{S^2(n)}, \qquad \hat C_j = \frac{1}{n-j}\sum_{i=1}^{n-j}\big(X_i - \bar X(n)\big)\big(X_{i+j} - \bar X(n)\big),

and plot ρ^j\hat\rho_j against j=1,2,…j = 1, 2, \dots: this is the correlation plot. Even for independent data ρ^j\hat\rho_j is never exactly 0, but it should stay close to 0 (a common rule of thumb: within ±2/n\pm 2/\sqrt n). Values clearly away from 0 indicate dependence. Since a correlation of 0 does not prove independence (§2.3), the plot can only detect dependence, not prove independence.

10−1lag j = 1, 2, …, 10independent data10−1lag j = 1, 2, …, 10positively correlated databars: sample correlation at lag j; dashed lines: ±2/√n (here n = 100)

  • Scatter diagram

Group the observations into pairs (Xi,Xi+1)(X_i, X_{i+1}), i=1,2,…,n−1i = 1, 2, \dots, n-1, and plot them as points.

If XiX_i and Xi+1X_{i+1} are positively correlated, then the points will approximately lie along a line with a positive slope (negatively correlated: negative slope). If they are independent, the points are scattered with no pattern.

independent: no patternXᵢXᵢ₊₁positively correlated: positive slopeXᵢXᵢ₊₁

  • Runs test

The runs-up test of Chapter 3 (§3.4.3). It uses only the order of the observations (which one is larger than which), so it works for any continuous data, not just U(0,1)U(0,1) numbers.

Three steps to fit a theoretical distribution

  1. Hypothesize a family of distributions (§5.4).
  2. Estimate the parameters of the distribution (maximum likelihood estimator, MLE).
  3. Determine the quality of fit (validation).

5.2. Review of distributions and their parameters

The types of parameters:

  • Location parameter γ\gamma

It determines the location of the distribution (where it sits on the xx-axis). Changing γ\gamma shifts the distribution but does not change its shape.

If XX has location parameter 00, then Y=X+γY = X + \gamma has location parameter γ\gamma. E.g. for N(μ,σ2)N(\mu, \sigma^2), μ\mu is the location parameter: if X∼N(0,σ2)X \sim N(0, \sigma^2), then X+μ∼N(μ,σ2)X + \mu \sim N(\mu, \sigma^2).

  • Scale parameter β\beta

It determines the scale / statistical dispersion of the distribution. Changing β\beta expands / compresses the distribution, but the distribution maintains its basic shape. If XX has scale parameter 11, then Y=βXY = \beta X has scale parameter β\beta.

E.g.

small σlarge σμN(μ, σ²)large λsmall λ0Exp(λ)small Llarge LaU(a, b), L = b − a

N(μ,σ2)N(\mu, \sigma^2) Exp(λ)\text{Exp}(\lambda) U(a,b)U(a, b)
σ\sigma is the scale parameter: if X∼N(0,1)X \sim N(0,1), then σX∼N(0,σ2)\sigma X \sim N(0, \sigma^2). (μ\mu is the location parameter.) Var⁡(X)=1/λ2\operatorname{Var}(X) = 1/\lambda^2. The scale parameter is β=1/λ\beta = 1/\lambda, the mean: if X∼Exp(1)X \sim \text{Exp}(1), then βX\beta X is exponential with mean β\beta. λ\lambda itself is a rate, so a large λ\lambda compresses the distribution. f(x)=1b−af(x) = \dfrac{1}{b-a}. Let L=b−aL = b - a and reparameterize U(a,b)U(a, b) by (a,L)(a, L): aa is the location and LL the scale parameter, since a+L U∼U(a,a+L)a + L\,U \sim U(a, a+L) for U∼U(0,1)U \sim U(0,1). The density height is 1/L1/L.
  • Shape parameter α\alpha

It determines the basic form or shape of the distribution, not just its position and spread.

Ex. Weibull distribution (α\alpha: shape, β\beta: scale):

f(x)=αβ−αxα−1e−(x/β)α,x>0.f(x) = \alpha\beta^{-\alpha}x^{\alpha-1}e^{-(x/\beta)^{\alpha}}, \qquad x > 0 .

α = 0.5 (α < 1)α = 2 (α > 1)α = 1 (exponential)0xf(x), β = 1

α<1\alpha < 1: decreasing density, with f(x)→∞f(x) \to \infty as x→0x \to 0. α=1\alpha = 1: the exponential distribution with mean β\beta. α>1\alpha > 1: a single hump, with f(0)=0f(0) = 0. (The normal and exponential families have no shape parameter: every normal density has the same bell shape.)

5.3. Fit an empirical distribution

  • Used when there is enough data and theoretical distributions do not work well.

Given nn observations X1,…,XnX_1, \dots, X_n, sort them: X(1)<X(2)<⋯<X(n)X_{(1)} < X_{(2)} < \dots < X_{(n)} (order statistics). F(X(i))=i/nF(X_{(i)}) = i/n.

Empirical c.d.f.:

F(x)=number of Xi’s≤xn.F(x) = \frac{\text{number of } X_i\text{'s} \le x}{n} .

X₍₁₎X₍₂₎X₍₃₎X₍₄₎X₍₅₎10step F (thin): jumps 1/n at each X₍ᵢ₎F (thick): straight linesthrough (X₍ᵢ₎, (i−1)/(n−1))~

For continuous data, use the interpolated (piecewise linear) version:

F~(x)={0,x<X(1),i−1n−1+x−X(i)(n−1)(X(i+1)−X(i)),X(i)≤x<X(i+1),i=1,…,n−1,1,x≥X(n).\tilde F(x) = \begin{cases} 0, & x < X_{(1)}, \\[4pt] \dfrac{i-1}{n-1} + \dfrac{x - X_{(i)}}{(n-1)\big(X_{(i+1)} - X_{(i)}\big)}, & X_{(i)} \le x < X_{(i+1)}, \quad i = 1, \dots, n-1, \\[10pt] 1, & x \ge X_{(n)} . \end{cases}

F~(X(i))=i−1n−1,F(X(i))=number of Xk’s≤X(i)n=in.\tilde F(X_{(i)}) = \frac{i-1}{n-1}, \qquad F(X_{(i)}) = \frac{\text{number of } X_k\text{'s} \le X_{(i)}}{n} = \frac{i}{n} .

Drawbacks

  1. The mean of F~\tilde F ≠Xˉ\ne \bar X. F~\tilde F spreads probability 1n−1\frac{1}{n-1} uniformly over each interval [X(i),X(i+1)][X_{(i)}, X_{(i+1)}], so its mean is 1n−1∑i=1n−1X(i)+X(i+1)2\frac{1}{n-1}\sum_{i=1}^{n-1}\frac{X_{(i)} + X_{(i+1)}}{2}, which in general differs from Xˉ\bar X. E.g. for the data 1.0,2.2,2.8,4.5,5.61.0, 2.2, 2.8, 4.5, 5.6: mean of F~\tilde F =3.20= 3.20, Xˉ=3.22\bar X = 3.22.
  2. Random values generated from F~\tilde F can never be smaller than X(1)X_{(1)} or larger than X(n)X_{(n)}.

Sampling from F~\tilde F (inverse transform, §4.2.1): generate u∼U(0,1)u \sim U(0,1), let P=(n−1)uP = (n-1)u and I=⌊P⌋+1I = \lfloor P \rfloor + 1, and return X=X(I)+(P−I+1)(X(I+1)−X(I))X = X_{(I)} + (P - I + 1)\big(X_{(I+1)} - X_{(I)}\big).

5.4. Step I: Hypothesize a distribution family

  • Prior knowledge of the random variable of interest
    • Service times should never be fitted using a normal distribution: a normal r.v. can be negative, a service time cannot (and service times are usually right-skewed, while the normal is symmetric).
    • Customers arrive at a bank one at a time (independently, at a roughly constant rate) ⇒ the arrival process is a Poisson process, so the interarrival times are exponential (§4.6).
  • Other heuristics
    • Summary statistics: mean, variance, min, max, mode. Also the median (mean ≈ median suggests a symmetric distribution) and the coefficient of variation σ/μ\sigma/\mu (equal to 1 for the exponential).
    • Histogram (choose an appropriate number of subintervals: too few hides the shape, too many makes it ragged; a common starting point is k≈1+log⁡2nk \approx 1 + \log_2 n, then try a few others). The shape of the histogram estimates the shape of the density.
    • Quantile summaries and boxplot.

Given q∈(0,1)q \in (0, 1), the qq-quantile is the value xqx_q such that P(X≤xq)≥qP(X \le x_q) \ge q and P(X≥xq)≥1−qP(X \ge x_q) \ge 1 - q. (For continuous FF: F(xq)=qF(x_q) = q, i.e. xq=F−1(q)x_q = F^{-1}(q). x0.5x_{0.5} is the median; x0.25x_{0.25} and x0.75x_{0.75} are the quartiles.)

For a given sample X1,X2,…,XnX_1, X_2, \dots, X_n with X(1)≤X(2)≤⋯≤X(n)X_{(1)} \le X_{(2)} \le \dots \le X_{(n)}, the sample 100q%100q\% quantile is

x^q={X(⌈nq⌉),if nq is not an integer,X(nq)+X(nq+1)2,if nq is an integer.\hat x_q = \begin{cases} X_{(\lceil nq \rceil)}, & \text{if } nq \text{ is not an integer}, \\[6pt] \dfrac{X_{(nq)} + X_{(nq+1)}}{2}, & \text{if } nq \text{ is an integer}. \end{cases}

Ex. n=10n = 10 service times, sorted: 0.2, 0.5, 0.7, 1.1, 1.4, 1.8, 2.3, 3.0, 4.2, 6.50.2,\ 0.5,\ 0.7,\ 1.1,\ 1.4,\ 1.8,\ 2.3,\ 3.0,\ 4.2,\ 6.5.

  • q=0.25q = 0.25: nq=2.5nq = 2.5 is not an integer ⇒ x^0.25=X(3)=0.7\hat x_{0.25} = X_{(3)} = 0.7.
  • q=0.5q = 0.5: nq=5nq = 5 is an integer ⇒ x^0.5=X(5)+X(6)2=1.4+1.82=1.6\hat x_{0.5} = \dfrac{X_{(5)} + X_{(6)}}{2} = \dfrac{1.4 + 1.8}{2} = 1.6.
  • q=0.75q = 0.75: nq=7.5nq = 7.5 ⇒ x^0.75=X(8)=3.0\hat x_{0.75} = X_{(8)} = 3.0.

Boxplot

Draws the five numbers xmin⁡, x^0.25, x^0.5, x^0.75, xmax⁡x_{\min},\ \hat x_{0.25},\ \hat x_{0.5},\ \hat x_{0.75},\ x_{\max}: a box from x^0.25\hat x_{0.25} to x^0.75\hat x_{0.75} with a line at the median, and whiskers out to the min and the max.

0.20.71.636.5box = middle half of the data; long right whisker ⇒ right-skewed sampleminx₀.₂₅median x₀.₅x₀.₇₅max

If the distribution is symmetric, the median sits in the middle of the box and the two whiskers have about the same length. Here the right whisker is much longer and the mean (2.172.17) exceeds the median (1.61.6): the sample is right-skewed, which, together with the values being nonnegative, already rules out the normal. (Some software stops the whiskers at 1.51.5 box-lengths and plots the points beyond them individually, as outliers.)

5.5. Step II: Estimate the Parameters

Maximum Likelihood Estimator (MLE)

Estimator: a statistic, i.e. a function of the random observations, whose value serves to estimate some unknown parameter of interest. If the parameter is θ\theta, then the estimator is denoted by θ^\hat\theta.

Ex. estimate μ\mu (and σ2\sigma^2) from X1,X2,…,XnX_1, X_2, \dots, X_n:

μ^=X1+⋯+Xnn≈μ,S2=∑i=1n(Xi−μ^)2n−1≈σ2.\hat\mu = \frac{X_1 + \cdots + X_n}{n} \approx \mu, \qquad S^2 = \frac{\sum_{i=1}^n (X_i - \hat\mu)^2}{n-1} \approx \sigma^2 .

The estimator is a function (of random variables, so it is itself a random variable). The estimate is the value of the function: once the observed values x1,…,xnx_1, \dots, x_n are plugged in, it becomes a number.

  1. Construct the likelihood function L(θ)L(\theta), which represents the probability (likelihood) that the sequence of observations x1,x2,…,xnx_1, x_2, \dots, x_n came from the distribution with parameter θ\theta. The data are fixed and LL is a function of θ\theta. Since the XiX_i’s are i.i.d. (§5.1), the joint probability is a product:
    1. Discrete case: L(θ)=Pθ(X1=x1,…,Xn=xn)=∏i=1npθ(xi)L(\theta) = P_\theta(X_1 = x_1, \dots, X_n = x_n) = \prod_{i=1}^n p_\theta(x_i)
    2. Continuous case: L(θ)=fθ(x1,…,xn)=∏i=1nfθ(xi)L(\theta) = f_\theta(x_1, \dots, x_n) = \prod_{i=1}^n f_\theta(x_i)
  2. Choose θ\theta to maximize L(θ)L(\theta). The MLE is

θ^=arg⁡max⁡θ∈ΘL(θ)=arg⁡max⁡θ∈Θln⁡L(θ),Θ=parameter set.\hat\theta = \arg\max_{\theta \in \Theta} L(\theta) = \arg\max_{\theta \in \Theta} \ln L(\theta), \qquad \Theta = \text{parameter set}.

Let l(θ)=ln⁡L(θ)l(\theta) = \ln L(\theta) → the log-likelihood function. Taking ln⁡\ln does not move the maximum (ln⁡\ln is increasing), and it turns the product into a sum, which is much easier to differentiate. In smooth cases, solve dl(θ)dθ=0\dfrac{dl(\theta)}{d\theta} = 0 and check d2l(θ)dθ2<0\dfrac{d^2 l(\theta)}{d\theta^2} < 0.

Ex: Exp(θ)\text{Exp}(\theta)

f(x)=1θe−x/θ,x≥0,E[X]=θf(x) = \frac{1}{\theta}e^{-x/\theta}, \quad x \ge 0, \qquad \mathbf{E}[X] = \theta

(the exponential parameterized by its mean: θ=β=1/λ\theta = \beta = 1/\lambda of §5.2). Given x1,x2,…,xnx_1, x_2, \dots, x_n:

L(θ)=∏i=1n1θe−xi/θ=1θnexp⁡(−1θ∑i=1nxi),L(\theta) = \prod_{i=1}^n \frac{1}{\theta}e^{-x_i/\theta} = \frac{1}{\theta^n}\exp\Big(-\frac{1}{\theta}\sum_{i=1}^n x_i\Big),

l(θ)=ln⁡L(θ)=−nln⁡θ−1θ∑i=1nxi,l(\theta) = \ln L(\theta) = -n\ln\theta - \frac{1}{\theta}\sum_{i=1}^n x_i,

dl(θ)dθ=−nθ+1θ2∑i=1nxi=0⇒θ^=1n∑i=1nxi=xˉ.\frac{dl(\theta)}{d\theta} = -\frac{n}{\theta} + \frac{1}{\theta^2}\sum_{i=1}^n x_i = 0 \quad\Rightarrow\quad \hat\theta = \frac{1}{n}\sum_{i=1}^n x_i = \bar x .

(Check: d2ldθ2=nθ2−2θ3∑xi\dfrac{d^2 l}{d\theta^2} = \dfrac{n}{\theta^2} - \dfrac{2}{\theta^3}\sum x_i, which at θ=xˉ\theta = \bar x equals −nxˉ2<0-\dfrac{n}{\bar x^2} < 0: a maximum.)

The meaning: θ\theta is the mean of the distribution, and its MLE is the sample mean, the most natural estimate.

Ex: Geo(θ)\text{Geo}(\theta) (modified)

p(x)=(1−θ)x θ,x=0,1,2,…p(x) = (1-\theta)^x\,\theta, \qquad x = 0, 1, 2, \dots

xx = number of trials before the first success, i.e. the number of failures (each trial is a success w.p. θ\theta). The geometric of §4.4 counts the trials up to and including the first success, P(X=k)=(1−θ)k−1θP(X = k) = (1-\theta)^{k-1}\theta, k=1,2,…k = 1, 2, \dots; here the exponent is xx, not x−1x - 1, because the modified XX = (usual XX) −1- 1. E[X]=1−θθ\mathbf{E}[X] = \dfrac{1-\theta}{\theta}.

L(θ)=∏i=1n(1−θ)xi θ=θn(1−θ)∑i=1nxi,L(\theta) = \prod_{i=1}^n (1-\theta)^{x_i}\,\theta = \theta^n (1-\theta)^{\sum_{i=1}^n x_i},

l(θ)=ln⁡L(θ)=nln⁡θ+(∑i=1nxi)ln⁡(1−θ),l(\theta) = \ln L(\theta) = n\ln\theta + \Big(\sum_{i=1}^n x_i\Big)\ln(1-\theta),

dl(θ)dθ=nθ−∑i=1nxi1−θ=0  ⇒  n(1−θ)=θ∑i=1nxi  ⇒  θ^=nn+∑i=1nxi=11+xˉ.\frac{dl(\theta)}{d\theta} = \frac{n}{\theta} - \frac{\sum_{i=1}^n x_i}{1-\theta} = 0 \;\Rightarrow\; n(1-\theta) = \theta\sum_{i=1}^n x_i \;\Rightarrow\; \hat\theta = \frac{n}{n + \sum_{i=1}^n x_i} = \frac{1}{1 + \bar x} .

(d2ldθ2=−nθ2−∑xi(1−θ)2<0\dfrac{d^2 l}{d\theta^2} = -\dfrac{n}{\theta^2} - \dfrac{\sum x_i}{(1-\theta)^2} < 0, so it is a maximum.)

The meaning: on average there are xˉ\bar x failures before each success, i.e. one success in every 1+xˉ1 + \bar x trials, so the estimated success probability is 1/(1+xˉ)1/(1 + \bar x). Equivalently, E[X]=1−θθ  ⟺  θ=11+E[X]\mathbf{E}[X] = \frac{1-\theta}{\theta} \iff \theta = \frac{1}{1 + \mathbf{E}[X]}, and the MLE simply replaces E[X]\mathbf{E}[X] by xˉ\bar x.

Ex: uniform distribution U(a,b)U(a, b)

Given x1,x2,…,xnx_1, x_2, \dots, x_n; the parameter is θ=(a,b)\theta = (a, b):

L(a,b)=∏i=1n1b−a=1(b−a)nif a≤xi≤b for all i,L(a, b) = \prod_{i=1}^n \frac{1}{b-a} = \frac{1}{(b-a)^n} \qquad \text{if } a \le x_i \le b \text{ for all } i,

and L(a,b)=0L(a, b) = 0 otherwise (if some xix_i lies outside [a,b][a, b], its density is 00). “All xi∈[a,b]x_i \in [a, b]” means a≤x(1)a \le x_{(1)} and b≥x(n)b \ge x_{(n)}.

Here setting the derivative to 00 does not work: 1/(b−a)n1/(b-a)^n has no stationary point, it just keeps increasing as b−ab - a shrinks. So make b−ab - a as small as the constraint allows, i.e. push aa up to x(1)x_{(1)} and bb down to x(n)x_{(n)}:

a^=x(1)=min⁡ixi,b^=x(n)=max⁡ixi.\hat a = x_{(1)} = \min_i x_i, \qquad \hat b = x_{(n)} = \max_i x_i .

x₍ₙ₎bmaximum at b = x₍ₙ₎ (the MLE)L = 1/(b − a)ⁿ, decreasing in bL = 0: x₍ₙ₎ would lie outside [a, b]L(a, b) as a function of b (a fixed at x₍₁₎)

Properties of MLEs

  1. Unique for many distribution families.
  2. Asymptotically unbiased: lim⁡n→∞E[θ^]=θ\lim_{n \to \infty}\mathbf{E}[\hat\theta] = \theta. For finite nn an MLE may be biased. E.g. for U(a,b)U(a, b), b^=X(n)≤b\hat b = X_{(n)} \le b always, and E[X(n)]=a+(b−a)nn+1<b\mathbf{E}[X_{(n)}] = a + (b - a)\frac{n}{n+1} < b, but it tends to bb as n→∞n \to \infty.
  3. Invariant: if instead of estimating θ\theta we want to estimate ϕ=h(θ)\phi = h(\theta), then the MLE is ϕ^=h(θ^)\hat\phi = h(\hat\theta). E.g. the rate of the exponential is λ=1/θ\lambda = 1/\theta, so λ^=1/xˉ\hat\lambda = 1/\bar x, without redoing the maximization.
  4. Strongly consistent: lim⁡n→∞θ^=θ\lim_{n \to \infty}\hat\theta = \theta w.p. 1 (as in the SLLN, §2.4).
  5. MLEs are asymptotically normal:

n (θ^−θ)→dN(0,δ(θ)),where δ(θ)=−nE[d2l(θ)dθ2],l(θ)=ln⁡L(θ).\sqrt n\,(\hat\theta - \theta) \xrightarrow{d} N\big(0, \delta(\theta)\big), \qquad \text{where } \delta(\theta) = \frac{-n}{\mathbf{E}\Big[\dfrac{d^2 l(\theta)}{d\theta^2}\Big]}, \quad l(\theta) = \ln L(\theta).

So

θ^−θδ(θ)/n→dZ∼N(0,1),P(−zα/2≤Z≤zα/2)=1−α.\frac{\hat\theta - \theta}{\sqrt{\delta(\theta)/n}} \xrightarrow{d} Z \sim N(0, 1), \qquad P\left(-z_{\alpha/2} \le Z \le z_{\alpha/2}\right) = 1 - \alpha .

A 100(1−α)%100(1-\alpha)\% CI for estimating θ\theta is

[θ^−zα/2δ(θ^)/n,    θ^+zα/2δ(θ^)/n ].\left[\hat\theta - z_{\alpha/2}\sqrt{\delta(\hat\theta)/n},\;\; \hat\theta + z_{\alpha/2}\sqrt{\delta(\hat\theta)/n}\,\right].

How to read property 5, step by step:

  • What it says. For large nn, θ^\hat\theta is approximately normal, centred at the true θ\theta, with variance δ(θ)/n\delta(\theta)/n: θ^≈N(θ,δ(θ)/n)\hat\theta \approx N\big(\theta, \delta(\theta)/n\big). Standardizing (subtract the mean, divide by the standard deviation) gives the ZZ above.
  • Same steps as CI Case 1 (§2.6.1), with Xˉ(n)\bar X(n) replaced by θ^\hat\theta and σ2/n\sigma^2/n by δ(θ)/n\delta(\theta)/n. Rearranging −zα/2≤θ^−θδ(θ)/n≤zα/2-z_{\alpha/2} \le \frac{\hat\theta - \theta}{\sqrt{\delta(\theta)/n}} \le z_{\alpha/2} gives θ^−zα/2δ(θ)/n≤θ≤θ^+zα/2δ(θ)/n\hat\theta - z_{\alpha/2}\sqrt{\delta(\theta)/n} \le \theta \le \hat\theta + z_{\alpha/2}\sqrt{\delta(\theta)/n}.
  • Why δ(θ^)\delta(\hat\theta) in the CI. δ(θ)\delta(\theta) depends on the unknown θ\theta, so we plug in the estimate θ^\hat\theta. For large nn this is fine because θ^→θ\hat\theta \to \theta (property 4).
  • Where δ\delta comes from. δ(θ)/n=−1/E[l′′(θ)]\delta(\theta)/n = -1/\mathbf{E}[l''(\theta)], and l′′(θ)l''(\theta) is the curvature of the log-likelihood. A sharply peaked ll (large ∣l′′∣|l''|) means the data strongly favour values near θ^\hat\theta: small variance, short CI. A flat ll means many values of θ\theta explain the data almost equally well: large variance, wide CI. Since ll is a sum of nn terms, E[l′′]\mathbf{E}[l''] is proportional to nn, so δ(θ)\delta(\theta) does not depend on nn, and the CI shrinks like 1/n1/\sqrt n.
  • Check with the exponential. From the example above, l′′(θ)=nθ2−2θ3∑xil''(\theta) = \frac{n}{\theta^2} - \frac{2}{\theta^3}\sum x_i, and E[Xi]=θ\mathbf{E}[X_i] = \theta, so E[l′′(θ)]=nθ2−2nθθ3=−nθ2\mathbf{E}[l''(\theta)] = \frac{n}{\theta^2} - \frac{2n\theta}{\theta^3} = -\frac{n}{\theta^2} and δ(θ)=θ2=Var⁡(X)\delta(\theta) = \theta^2 = \operatorname{Var}(X). Since θ^=Xˉ\hat\theta = \bar X, property 5 is just the CLT for Xˉ\bar X (§2.4), and the CI is xˉ±zα/2 xˉ/n\bar x \pm z_{\alpha/2}\,\bar x/\sqrt n: Case 1 of §2.6.1 with σ\sigma replaced by its MLE θ^=xˉ\hat\theta = \bar x.

n = 10: flat peakn = 50: sharp peakpeak at θ = 2 (the MLE)θ0l(θ) − l(MLE)90% CI, n = 10: [0.96, 3.04]90% CI, n = 50: [1.53, 2.47]

The log-likelihood of the exponential example with xˉ=2\bar x = 2, for n=10n = 10 and n=50n = 50, and the 90% CIs xˉ±1.645 xˉ/n\bar x \pm 1.645\,\bar x/\sqrt n: the sharper the peak, the shorter the interval.

Ex: construct a 90% CI for θ\theta in the modified geometric distribution Geo(θ)\text{Geo}(\theta).

p(x)=P(X=x)=θ(1−θ)xp(x) = P(X = x) = \theta(1-\theta)^x, x=0,1,2,…x = 0, 1, 2, \dots, E[X]=1−θθ\mathbf{E}[X] = \dfrac{1-\theta}{\theta}.

Given x1,…,xnx_1, \dots, x_n (from the example above):

L(θ)=θn(1−θ)∑i=1nxi,l(θ)=nln⁡θ+(∑i=1nxi)ln⁡(1−θ),L(\theta) = \theta^n (1-\theta)^{\sum_{i=1}^n x_i}, \qquad l(\theta) = n\ln\theta + \Big(\sum_{i=1}^n x_i\Big)\ln(1-\theta),

dl(θ)dθ=nθ−∑xi1−θ,d2l(θ)dθ2=−nθ2−∑xi(1−θ)2.\frac{dl(\theta)}{d\theta} = \frac{n}{\theta} - \frac{\sum x_i}{1-\theta}, \qquad \frac{d^2 l(\theta)}{d\theta^2} = -\frac{n}{\theta^2} - \frac{\sum x_i}{(1-\theta)^2} .

Take expectations, using E[∑Xi]=n E[X]=n1−θθ\mathbf{E}\big[\sum X_i\big] = n\,\mathbf{E}[X] = n\frac{1-\theta}{\theta}:

E[d2l(θ)dθ2]=−nθ2−n(1−θ)/θ(1−θ)2=−nθ2−nθ(1−θ)=−n[(1−θ)+θ]θ2(1−θ)=−nθ2(1−θ).\mathbf{E}\Big[\frac{d^2 l(\theta)}{d\theta^2}\Big] = -\frac{n}{\theta^2} - \frac{n(1-\theta)/\theta}{(1-\theta)^2} = -\frac{n}{\theta^2} - \frac{n}{\theta(1-\theta)} = -\frac{n\big[(1-\theta) + \theta\big]}{\theta^2(1-\theta)} = -\frac{n}{\theta^2(1-\theta)} .

So δ(θ)=−nE[d2l/dθ2]=θ2(1−θ)\delta(\theta) = \dfrac{-n}{\mathbf{E}[d^2 l/d\theta^2]} = \theta^2(1-\theta).

CI: with θ^=11+xˉ\hat\theta = \dfrac{1}{1 + \bar x} and 1−α=0.91 - \alpha = 0.9, zα/2=z0.05=1.645z_{\alpha/2} = z_{0.05} = 1.645:

[θ^−1.645θ^2(1−θ^)n,    θ^+1.645θ^2(1−θ^)n ].\left[\hat\theta - 1.645\sqrt{\frac{\hat\theta^2(1-\hat\theta)}{n}},\;\; \hat\theta + 1.645\sqrt{\frac{\hat\theta^2(1-\hat\theta)}{n}}\,\right].

E.g. n=50n = 50 observations with xˉ=2\bar x = 2: θ^=1/3\hat\theta = 1/3, δ(θ^)=19⋅23=0.0741\delta(\hat\theta) = \frac19 \cdot \frac23 = 0.0741, δ(θ^)/n=0.0385\sqrt{\delta(\hat\theta)/n} = 0.0385, so the 90% CI is 0.333±1.645×0.0385=[0.270, 0.397]0.333 \pm 1.645 \times 0.0385 = [0.270,\ 0.397].

5.6. Step III: Determine the Quality of Fit

  1. Graphical methods
    1. quantile–quantile plot (Q–Q plot)
    2. probability–probability plot (P–P plot)
  2. Statistical methods
    1. chi-square test
    2. Kolmogorov–Smirnov (K–S) test

Running example (used for the plots and the test below). n=20n = 20 interarrival times, sorted:

0.16, 0.18, 0.19, 0.38, 0.41, 0.90, 1.05, 1.08, 1.19, 1.22, 1.32, 1.38, 1.43, 1.97, 2.09, 2.19, 2.29, 2.53, 2.55, 2.95.0.16,\ 0.18,\ 0.19,\ 0.38,\ 0.41,\ 0.90,\ 1.05,\ 1.08,\ 1.19,\ 1.22,\ 1.32,\ 1.38,\ 1.43,\ 1.97,\ 2.09,\ 2.19,\ 2.29,\ 2.53,\ 2.55,\ 2.95 .

Step I: hypothesize an exponential distribution. Step II: the MLE of its mean is θ^=xˉ=27.46/20=1.373\hat\theta = \bar x = 27.46/20 = 1.373, so F^(x)=1−e−x/1.373\hat F(x) = 1 - e^{-x/1.373}. Step III asks how well this F^\hat F fits. (The numbers were simulated from an exponential distribution, so the exponential family is in fact correct here.)

Graphical methods

Q–Q plot

Let F^\hat F be the fitted theoretical distribution and F~\tilde F the empirical distribution based on x1,…,xnx_1, \dots, x_n. A Q–Q plot is a graph of the qiq_i-quantile of F^\hat F vs the qiq_i-quantile of F~\tilde F.

F(x)=number of xi’s≤xn,F~(x)=F(x)−0.5n,qi=i−0.5n,i=1,…,n.F(x) = \frac{\text{number of } x_i\text{'s} \le x}{n}, \qquad \tilde F(x) = F(x) - \frac{0.5}{n}, \qquad q_i = \frac{i - 0.5}{n}, \quad i = 1, \dots, n .

(This F~\tilde F, the empirical c.d.f. shifted down by 0.5/n0.5/n, is not the interpolated F~\tilde F of §5.3.)

F~(x(1))=1n−0.5n=1−0.5n=q1\tilde F(x_{(1)}) = \frac{1}{n} - \frac{0.5}{n} = \frac{1 - 0.5}{n} = q_1, and in general F~(x(i))=i−0.5n=qi\tilde F(x_{(i)}) = \frac{i - 0.5}{n} = q_i ⇒ the qiq_i-quantile of F~\tilde F is just x(i)x_{(i)}.

Why 0.5/n0.5/n? Without this term, qn=n/n=1q_n = n/n = 1, and we would need the 1-quantile of F^\hat F. For a distribution with infinite range, like the normal or the exponential, F^−1(1)=+∞\hat F^{-1}(1) = +\infty: not possible. With the 0.5/n0.5/n, every qiq_i lies strictly inside (0,1)(0, 1), and symmetrically: q1=0.5nq_1 = \frac{0.5}{n}, qn=1−0.5nq_n = 1 - \frac{0.5}{n}.

Plot xqiM=F^−1(qi)x^M_{q_i} = \hat F^{-1}(q_i) (model quantile) as a function of xqiS=x(i)x^S_{q_i} = x_{(i)} (sample quantile), i=1,…,ni = 1, \dots, n. If F^\hat F fits well, the points lie close to the 45°45° line y=xy = x.

10qᵢx₍ᵢ₎xMhorizontal gapFˆF~001122334455sample quantile x₍ᵢ₎model quantile Fˆ⁻¹(qᵢ)y = x

Left: at height qiq_i, read the sample quantile x(i)x_{(i)} off the staircase F~\tilde F and the model quantile xM=F^−1(qi)x^M = \hat F^{-1}(q_i) off the curve F^\hat F. The Q–Q plot compares these two x-values (a horizontal gap). Right: the Q–Q plot of the running example, with F^−1(q)=−1.373ln⁡(1−q)\hat F^{-1}(q) = -1.373\ln(1-q). The points follow the line except at the upper end: the two largest observations, 2.552.55 and 2.952.95, are much smaller than the model quantiles 3.563.56 and 5.065.06, i.e. the sample has a shorter right tail than the fitted exponential.

Used for continuous distributions (it needs the quantile function F^−1\hat F^{-1}; for a discrete F^\hat F many qiq_i share the same quantile, and the plot shows little).

P–P plot

A P–P plot is a graph of the model probability F^(x(i))\hat F(x_{(i)}) vs the sample probability F~(x(i))=qi=i−0.5n\tilde F(x_{(i)}) = q_i = \frac{i - 0.5}{n}, for i=1,…,ni = 1, \dots, n. Used for both continuous and discrete data sets. If F^\hat F fits well, the points lie close to the line y=xy = x in [0,1]2[0, 1]^2.

10x₍ᵢ₎Fˆ(x₍ᵢ₎)qᵢvertical gapFˆF~000.50.511sample probability qᵢmodel probability Fˆ(x₍ᵢ₎)y = x

Left: at x(i)x_{(i)}, read the probability on the curve F^\hat F and on the staircase F~\tilde F. The P–P plot compares these two probabilities (a vertical gap). Right: the P–P plot of the running example. The largest deviations are in the middle, e.g. F^(x(6))=F^(0.90)=0.48\hat F(x_{(6)}) = \hat F(0.90) = 0.48 vs q6=0.275q_6 = 0.275 (the sample has no observations between 0.410.41 and 0.900.90). At the upper end the points are much closer to the line: the short right tail that stands out in the Q–Q plot is barely visible here.

Q–Q or P–P?

A small change in the tail causes a large gap in the Q–Q plot. In the tails F^\hat F is flat (the density is small), so a tiny difference in probability corresponds to a large difference in xx; the Q–Q plot compares x-values, so differences in the tails are magnified. In the middle F^\hat F is steep, so a small difference in xx corresponds to a large difference in probability; the P–P plot compares probabilities, so differences in the middle are magnified. (In the tails both F^\hat F and F~\tilde F are close to 00 or 11, so the P–P points crowd into the corners and tail differences are hidden.)

Δx = 0.08middle: F steep —Δp = 0.03 ↔ Δx = 0.08Δx = 0.41tail: F flat —Δp = 0.03 ↔ Δx = 0.4110xQ–Q compares x-values (horizontal), P–P compares probabilities (vertical)

  • If you want to know whether F^\hat F provides a good approximation of F~\tilde F in the tails → Q–Q plot.
  • If you want to check the middle (the bulk) of the distribution → P–P plot. It is also the one of the two that works for discrete data.

The running example shows both effects on the same data: the Q–Q plot’s biggest gap is in the right tail, the P–P plot’s in the middle.

Goodness-of-fit tests (hypothesis tests)

They test the null hypothesis

H0:the Xi’s are i.i.d. with distribution F^.H_0: \text{the } X_i\text{'s are i.i.d. with distribution } \hat F .

As with the RNG tests (§3.4), “do not reject H0H_0” does not prove that F^\hat F is correct, only that the data show no evidence against it. The sample size matters: with little data almost nothing is rejected, and with a lot of data almost every F^\hat F is rejected, since no theoretical distribution fits real data exactly.

Chi-square test

  1. Split the range of F^\hat F (not the range of x1,…,xnx_1, \dots, x_n) into kk adjacent intervals [a0,a1),[a1,a2),…,[ak−1,ak)[a_0, a_1), [a_1, a_2), \dots, [a_{k-1}, a_k). It is possible that a0=−∞a_0 = -\infty and/or ak=+∞a_k = +\infty. (Every value that F^\hat F can produce must fall in some interval, so that the pjp_j in step 3 add up to 1.)
  2. Count the number of xix_i’s in each interval: fjf_j = number of xix_i’s in the jj-th interval, ∑j=1kfj=n\sum_{j=1}^k f_j = n.
  3. Assume H0H_0 is true; compute the expected proportion pjp_j of xix_i’s that would fall in the jj-th interval:

pj=∫aj−1ajf^(x) dx=F^(aj)−F^(aj−1)(continuous),pj=∑aj−1≤x<ajp^(x)(discrete),p_j = \int_{a_{j-1}}^{a_j} \hat f(x)\,dx = \hat F(a_j) - \hat F(a_{j-1}) \quad \text{(continuous)}, \qquad p_j = \sum_{a_{j-1} \le x < a_j} \hat p(x) \quad \text{(discrete)},

where in the discrete case the sum runs over the possible values xx of the fitted distribution (not over the data). The expected number in interval jj is npjnp_j.
4. Test statistic

χ2=∑j=1k(fj−npj)2npj.\chi^2 = \sum_{j=1}^k \frac{(f_j - np_j)^2}{np_j} .

Reject H0H_0 at significance level α\alpha if χ2>χk−1, α2\chi^2 > \chi^2_{k-1,\,\alpha} (see the χ2\chi^2 table).

Remarks.

  • It is the same statistic as the RNG uniformity test of §3.4.1, which is the special case F^=U(0,1)\hat F = U(0,1) with kk equal intervals, pj=1/kp_j = 1/k.
  • Choosing the intervals: a common choice is equiprobable intervals, pj=1/kp_j = 1/k, i.e. aj=F^−1(j/k)a_j = \hat F^{-1}(j/k), with npj≥5np_j \ge 5 (as in §3.4.1).
  • Degrees of freedom. If mm parameters of F^\hat F were estimated from the same data (e.g. by MLE), the distribution of χ2\chi^2 under H0H_0 lies between χk−m−12\chi^2_{k-m-1} and χk−12\chi^2_{k-1}. Using χk−1,α2\chi^2_{k-1,\alpha}, as in step 4, is conservative: the actual probability of a type I error is at most α\alpha. So if χ2≤χk−m−1,α2\chi^2 \le \chi^2_{k-m-1,\alpha}, do not reject; if χ2>χk−1,α2\chi^2 > \chi^2_{k-1,\alpha}, reject; in between, the decision depends on which critical value is used.

Example (running example, F^\hat F = exponential with θ^=1.373\hat\theta = 1.373). Take k=4k = 4 equiprobable intervals, so npj=20/4=5np_j = 20/4 = 5, with boundaries aj=F^−1(j/4)=−1.373ln⁡(1−j/4)a_j = \hat F^{-1}(j/4) = -1.373\ln(1 - j/4):

jj interval fjf_j npjnp_j (fj−npj)2/npj(f_j - np_j)^2/np_j
1 [0, 0.395)[0,\ 0.395) 4 5 0.2
2 [0.395, 0.952)[0.395,\ 0.952) 2 5 1.8
3 [0.952, 1.903)[0.952,\ 1.903) 7 5 0.8
4 [1.903, ∞)[1.903,\ \infty) 7 5 0.8
total 20 20 χ2=3.6\chi^2 = 3.6

m=1m = 1 parameter was estimated, so the critical value at α=0.05\alpha = 0.05 is between χ2, 0.052=5.991\chi^2_{2,\,0.05} = 5.991 and χ3, 0.052=7.815\chi^2_{3,\,0.05} = 7.815. Since χ2=3.6<5.991\chi^2 = 3.6 < 5.991, do not reject H0H_0 either way: no evidence against the exponential fit.

Note what the test cannot see: interval 4 only counts how many observations exceed 1.9031.903 (7, close to the expected 5), not how far out they go, so the short right tail visible in the Q–Q plot does not affect χ2\chi^2. With n=20n = 20 that short tail is a chance feature of the sample anyway, since the data do come from an exponential.


5. Selecting Input Probability Distributions
http://example.com/2026/09/08/2026-09-08-selecting-input-probability-distributions/
Author
Wind_like
Posted on
September 8, 2026
Licensed under