Build inputs from evidenceLesson 21 of 76 · 8 min
Fit a shape and inspect the fit
Fit a positive distribution and compare its quantiles with the input evidence.
A fitted distribution estimates parameters from observations. It can interpolate between observed values and extrapolate beyond them, but its shape is another assumption. Parameter fitting does not establish that the distribution is suitable.
Fit a lognormal model to invented positive waits with loc=0. SciPy's shape is the SD of log(wait), and scale is exp(the mean of log(wait)); loc shifts the whole distribution. For NumPy's earlier generator this means SciPy shape=log_sd and scale=exp(log_mean). For example, log_mean=log(10) and log_sd=.7 correspond to shape=.7, loc=0, scale=10.
Compare empirical and fitted quantiles before using the fitted tail in a decision. A reasonably matching centre does not guarantee a matching tail. With a small sample, both fit assessment and parameter estimates are uncertain, so retain the observations and show sensitivity to plausible alternatives.
means fitted parameters; the hat marks an estimate from the finite observations.
- Input evidence
observed durations
- Fit a positive distribution
- Compare quantiles
empirical versus fitted
Does a successful fit call establish that the fitted tail is realistic?
Write a prediction (optional)
Seeded teaching simulation
Select Run Python below with the code unchanged.
A saved draft is open. To run the published example, open Tools and select Restore example. Recover draft brings your code back.
Execution error
Technical error details
Your result
Published example output
This result comes from the original Python. Your runs appear above. Build environment ↗
Empirical quantiles: [1.56 2.65 5.49] Fitted quantiles: [1.4 2.742 5.371] Fitted shape, loc, scale: 0.5246 0 2.742
Read the first result
The fitted model makes predictions between and beyond observations. Those predictions need validation, not merely a converged optimiser.
Try an edit
Record the first quantiles. Delete , 7.2 from the end of observed for a separate comparison. Select Run Python again. Compare the last values in Empirical quantiles and Fitted quantiles with the first run. What did the model’s fitted P90 do when the largest observation was omitted?
Scope. Ten invented values are not sufficient to establish a reliable real-world tail. The fit also treats observations as independent.
Try a fresh case
Two candidate models fit the middle of a small sample similarly but predict different extremes. What is useful?
Need a hint?
Hint 1
Identify which part of the distribution the decision uses.
Hint 2
Compare the candidate predictions in that region.