Fitting a distribution
Before estimating anything you have to commit to a model. These sections fit the two skewed models the assignments used — the exponential and the lognormal — estimate their parameters by maximum likelihood, and check the fit with quantiles.
The assignment datasets are not reproduced here; each lab starts with a simulated sample of the same size and shape. Paste any data to analyse it, and compare the 2020 results in the margin.
§2.1Coursework A1 Q1
An exponential model and its QQ plot
Thirty plant heights, measured after six weeks, were strongly right-skewed. For an exponential model with mean θ the log-likelihood is maximised at the sample mean, .
To judge the fit, the notebook compared Type 6 sample quantiles, which interpolate the order statistics at position , with the model quantiles. Against Exp(1) the same points fall on a line of slope 1/θ instead of 1, so either reference works.
30 positive values
Compare against
Median
69.6
IQR 105.4
Mean
110.6
range 0.1 – 586.8
MLE θ̂ = x̄
110.59
Reference line
slope 1
y = x
- Type 6 sample quantile vs model quantile
- Reference line, slope 1
Show the numbers as a table
| p | sample (type 6) | theoretical |
|---|---|---|
| 0.00 | 0.100 | 0.0000 |
| 0.01 | 0.100 | 1.0050 |
| 0.02 | 0.100 | 2.0203 |
| 0.03 | 0.100 | 3.0459 |
| 0.04 | 1.972 | 4.0822 |
| 0.05 | 4.390 | 5.1293 |
| 0.06 | 6.808 | 6.1875 |
| 0.07 | 8.512 | 7.2571 |
| 0.08 | 9.628 | 8.3382 |
| 0.09 | 10.744 | 9.4311 |
| 0.10 | 11.890 | 10.5361 |
| 0.11 | 13.099 | 11.6534 |
| 0.12 | 14.308 | 12.7833 |
| 0.13 | 15.406 | 13.9262 |
| 0.14 | 15.468 | 15.0823 |
| 0.15 | 15.530 | 16.2519 |
| 0.16 | 15.592 | 17.4353 |
| 0.17 | 17.787 | 18.6330 |
| 0.18 | 20.298 | 19.8451 |
| 0.19 | 22.809 | 21.0721 |
| 0.20 | 23.760 | 22.3144 |
| 0.21 | 23.853 | 23.5722 |
| 0.22 | 23.946 | 24.8461 |
| 0.23 | 24.130 | 26.1365 |
| 0.24 | 24.440 | 27.4437 |
| 0.25 | 24.750 | 28.7682 |
| 0.26 | 25.264 | 30.1105 |
| 0.27 | 26.628 | 31.4711 |
| 0.28 | 27.992 | 32.8504 |
| 0.29 | 29.356 | 34.2490 |
| 0.30 | 31.950 | 35.6675 |
| 0.31 | 34.585 | 37.1064 |
| 0.32 | 37.220 | 38.5662 |
| 0.33 | 40.407 | 40.0478 |
| 0.34 | 43.786 | 41.5515 |
| 0.35 | 47.165 | 43.0783 |
| 0.36 | 48.928 | 44.6287 |
| 0.37 | 49.176 | 46.2035 |
| 0.38 | 49.424 | 47.8036 |
| 0.39 | 49.897 | 49.4296 |
| 0.40 | 50.920 | 51.0826 |
| 0.41 | 51.943 | 52.7633 |
| 0.42 | 53.116 | 54.4727 |
| 0.43 | 56.464 | 56.2119 |
| 0.44 | 59.812 | 57.9818 |
| 0.45 | 63.160 | 59.7837 |
| 0.46 | 64.090 | 61.6186 |
| 0.47 | 64.555 | 63.4878 |
| 0.48 | 65.020 | 65.3926 |
| 0.49 | 66.872 | 67.3345 |
| 0.50 | 69.600 | 69.3147 |
| 0.51 | 72.328 | 71.3350 |
| 0.52 | 74.204 | 73.3969 |
| 0.53 | 74.731 | 75.5023 |
| 0.54 | 75.258 | 77.6529 |
| 0.55 | 77.305 | 79.8508 |
| 0.56 | 87.256 | 82.0981 |
| 0.57 | 97.207 | 84.3970 |
| 0.58 | 107.158 | 86.7501 |
| 0.59 | 108.844 | 89.1598 |
| 0.60 | 109.960 | 91.6291 |
| 0.61 | 111.076 | 94.1609 |
| 0.62 | 112.456 | 96.7584 |
| 0.63 | 113.944 | 99.4252 |
| 0.64 | 115.432 | 102.1651 |
| 0.65 | 117.760 | 104.9822 |
| 0.66 | 120.984 | 107.8810 |
| 0.67 | 124.208 | 110.8663 |
| 0.68 | 126.632 | 113.9434 |
| 0.69 | 126.756 | 117.1183 |
| 0.70 | 126.880 | 120.3973 |
| 0.71 | 127.060 | 123.7874 |
| 0.72 | 128.920 | 127.2966 |
| 0.73 | 130.780 | 130.9333 |
| 0.74 | 132.640 | 134.7074 |
| 0.75 | 134.350 | 138.6294 |
| 0.76 | 136.024 | 142.7116 |
| 0.77 | 137.698 | 146.9676 |
| 0.78 | 139.048 | 151.4128 |
| 0.79 | 140.164 | 156.0648 |
| 0.80 | 141.280 | 160.9438 |
| 0.81 | 147.951 | 166.0731 |
| 0.82 | 164.722 | 171.4798 |
| 0.83 | 181.493 | 177.1957 |
| 0.84 | 197.148 | 183.2581 |
| 0.85 | 205.270 | 189.7120 |
| 0.86 | 213.392 | 196.6113 |
| 0.87 | 221.514 | 204.0221 |
| 0.88 | 225.156 | 212.0264 |
| 0.89 | 228.318 | 220.7275 |
| 0.90 | 231.480 | 230.2585 |
| 0.91 | 279.687 | 240.7946 |
| 0.92 | 349.344 | 252.5729 |
| 0.93 | 419.001 | 265.9260 |
| 0.94 | 475.344 | 281.3411 |
| 0.95 | 515.520 | 299.5732 |
| 0.96 | 555.696 | 321.8876 |
| 0.97 | 586.800 | 350.6558 |
| 0.98 | 586.800 | 391.2023 |
| 0.99 | 586.800 | 460.5170 |
§2.2Coursework A1 Q2
A lognormal model and an interval for its variance
If then the MLEs are the mean and the divide-by-n variance of the logged data. Because , the 2020 working derived
and the port implements those formulas exactly as they were submitted.
15 values
μ̂ = mean of ln x
1.8519
λ̂ (MLE)
1.7865
se(λ̂) = λ̂√(2/(n−1))
0.675245
95% CI for λ, as submitted
(0.9576, 4.444)
textbook SS/χ²: (1.026, 4.761)
- ln xᵢ
- Fitted N(μ̂, λ̂) density
- 95% interval for the spread, as ±√λ around μ̂
§2.3Coursework A3 Q2
How precise is a sample quantile?
For the exponential, inverts to . The Type 7 sample quantile interpolates the order statistics at position , and for large n
With n = 30 and p = 0.25 the variance is , so the standard error is .
30 values
π̂ (Type 7), p = 0.25
4.830
k = 1 + (n−1)p = 8.25
λ̂ = 1 / x̄
0.1336
Model πₚ = −ln(1−p)/λ̂
2.153
Asymptotic se
0.789
≈95% CI (3.28, 6.38)
- Empirical CDF
- Fitted Exp(λ̂) CDF
- ±1.96 se around π̂