Probabilistic forecasting: quantiles, CRPS and conformal intervals
Before this lesson: backtesting and point metrics (lesson 03), ARIMA prediction intervals (lesson 06), forecasting with lag features and gradient boosting (lesson 08). From the probability-and-statistics track: the cumulative distribution function (CDF), quantiles, and the normal distribution. Calibration of classifiers from the ml-fundamentals track helps, but this lesson defines everything it uses. Time: about 110 minutes, plus the notebook.
Why this matters #
- Decisions depend on quantiles, not on the mean. A shop that loses 9 per missing unit and 1 per unsold unit should stock the 90 % quantile of demand (section 3.2). A grid operator keeps reserve power for the 99 % quantile of load. A point forecast cannot answer these questions.
- Model intervals are often too narrow. The ARIMA and ETS intervals of lessons 04 and 06 assume that the model is right, that its parameters are exact and that the errors are Gaussian. In real backtests a "95 %" interval often covers clearly less than 95 % of the outcomes. Conformal methods correct this.
- Benchmarks and competitions score distributions. The M5 uncertainty competition scored nine quantiles with a scaled pinball loss; the GEFCom2014 energy competition used the pinball loss; weather ensembles (ECMWF, and ML models such as GenCast) are scored with the CRPS; time-series foundation models such as Chronos and TimesFM output quantiles and are compared by a weighted quantile loss (lesson 09).
- Monitoring. A value outside a calibrated 99 % interval is a natural anomaly alarm (lesson 11).
1. Predict first #
2. The picture #
Four forms of a probabilistic forecast #
Write for the unknown future value and for a point forecast made at the forecast origin (the track notation). A probabilistic forecast describes the whole predictive distribution of given the data up to time . It comes in four forms:
| Form | What the model outputs | Example | Good for |
|---|---|---|---|
| distribution | a CDF or its parameters | from ARIMA (lesson 06) | any summary of one horizon |
| quantiles | for a few levels | from a quantile model | decisions at fixed levels |
| interval | with nominal coverage | a 90 % interval | dashboards, alarms |
| sample paths | simulated futures | DeepAR samples (lesson 09) | sums and maxima over many horizons |
The first three describe one horizon at a time (the marginal distribution of each ). Only sample paths keep the dependence between horizons. You need them for questions about several horizons at once, such as "what is the 90 % quantile of the total demand next week?" (section 3.7).
The pinball loss turns a quantile into a training target #
The -quantile of a distribution is the value with probability below it. To train a model to output a quantile, we need a loss whose best constant is that quantile. The squared error gives the mean, and the absolute error gives the median (lesson 03). The pinball loss (or quantile loss) tilts the absolute error: with the error ,
For , a forecast that is too low costs per unit and a forecast that is too high costs only per unit. So the best moves up, until only 10 % of the data lie above it.
Move , then move . The top panel is the loss of one error : slope on the right and on the left. The lower panel shows 39 blue data values and the orange mean loss over them. Its slope at is the share of data below minus . Notice that the yellow minimum sits where the share below reaches : at the empirical -quantile. Press Move q to the minimum and compare with the order statistic.
Calibration and sharpness #
How do we check a probabilistic forecast? We cannot check one distribution with one outcome. But over many forecasts, events with a forecast probability of 80 % should happen about 80 % of the time. This is calibration. A simple check is the coverage of central intervals: the share of outcomes inside the 50 %, 80 % and 95 % intervals. A finer check is the PIT (probability integral transform): for each forecast, compute , the forecast probability below the outcome. If the forecasts are calibrated, the are uniform on and their histogram is flat.
Calibration is not enough. A forecast that ignores all current information and always predicts the long-run distribution of the series (the climatological forecast) is calibrated, but its intervals are wide. We also want sharpness: narrow intervals. The rule of Gneiting, Balabdaoui and Raftery (2007) is maximise sharpness subject to calibration.
Pick a preset, then move the spread and the bias. Each of 300 cases has a known signal and a noisy outcome ; the forecast is . The top panel shows the first 60 outcomes and their 80 % intervals; magenta outcomes fall outside. Too narrow gives a U-shaped PIT histogram and low coverage; too wide gives a hump; biased gives a slope. Notice that the flat PIT at also has (up to sampling noise) the smallest mean CRPS (section 3.4), and that climatology is calibrated but has a much larger CRPS.
The PIT histogram of a forecaster over one year is U-shaped: many values near 0 and near 1, few in the middle. What is wrong?
is near 0 or 1 when lies far in a tail of its forecast distribution. Too many such cases mean that the forecast distributions are too narrow (over-confident, under-dispersed). Too-wide forecasts put the outcomes near the centre and give a hump. A bias moves the mass to one side and gives a slope.
3. Definitions and main results #
3.1 Notation #
- is the predictive CDF of given the data up to : under the forecast. We drop the indices when only one forecast is meant.
- The quantile function is for . A quantile forecast at level is written .
- A central interval is . Its nominal coverage is ; its empirical coverage is the share of outcomes inside it in a backtest.
3.2 Quantiles and the pinball loss #
Definition. For a level , the pinball loss of a quantile forecast when the outcome is is
For it is half the absolute error. It is never negative and it is 0 only when .
Theorem (the pinball loss is minimised by the quantile). Let have a continuous CDF with finite mean. Then is convex in , and it is minimised at every with , that is at the -quantile .
Why this is true, in one sentence. Moving up by a small costs for each outcome below (probability ) and saves for each outcome above (probability ). The net change is .
Proof.
- Split the expectation at : .
- Differentiate with respect to . The integrands are 0 at , so only the derivative of the integrands counts: .
- is non-decreasing, so is non-decreasing and is convex.
- when and when . So decreases up to the -quantile and increases after it: the minimum is where .
The empirical version. For a sample , the mean loss
is piecewise linear with kinks at the data. Its slope is
, where is the share of data . If is not an integer, the unique
minimiser is the -th smallest value (np.quantile(y, tau, method="inverted_cdf")). If
is an integer, every between the -th and the -th smallest value is a
minimiser.
Quantile regression. Replace the constant by a model and minimise the mean pinball loss over the training data. This is quantile regression (Koenker and Bassett, 1978). The theorem, applied for each , says that the best model outputs the conditional -quantile of given . It works with any model:
- linear:
sklearn.linear_model.QuantileRegressor(quantile=0.9)(a linear program); - gradient boosting:
HistGradientBoostingRegressor(loss="quantile", quantile=0.9)on the lag features of lesson 08; LightGBM hasobjective="quantile"; - neural networks: a multi-quantile head outputs together and is trained with (MQ-RNN, the Temporal Fusion Transformer, Chronos-Bolt; lesson 09).
Quantile crossing. Models trained separately for each can give for some . This is impossible for a real distribution. Simple fixes: sort the predicted quantiles at each (this never increases the total pinball loss; Chernozhukov, Fernández-Val and Galichon, 2010), or predict and positive increments .
The stocking decision (newsvendor problem). Order units. Each unsold unit costs and each missing unit costs . The cost is if and if . This is with . By the theorem, the best order is the quantile at the critical ratio . With and : . This answers question 1 of section 1: order the 90 % quantile of demand, not the mean or the median.
A model is trained with the pinball loss at on a large data set. What does its output estimate?
The expected pinball loss has derivative , which is zero where . A forecast that is too low costs per unit and one that is too high only , so the minimiser moves up to the 90 % quantile. The upper end of a 90 % central interval is the 95 % quantile. "Mean plus 0.9 sd" is a quantile only for a specific distribution.
3.3 Calibration, sharpness and the PIT #
Definition. A sequence of forecasts for outcomes is probabilistically calibrated if the PIT values are uniform on . Equivalently, for every level , the share of outcomes below is ; so every central interval covers of the outcomes.
Theorem (the PIT of the true distribution is uniform). If has a continuous CDF , then is uniform on .
Proof. For , let ; continuity gives . Then , which is the CDF of the uniform distribution.
So a forecaster that knows the true conditional distribution produces a flat PIT histogram. How to read a histogram that is not flat:
| PIT histogram | Coverage of central intervals | Diagnosis |
|---|---|---|
| flat | as nominal | calibrated |
| U-shaped | below nominal | too narrow (under-dispersed, over-confident) |
| hump in the middle | above nominal | too wide (over-dispersed) |
| sloped (mass near 0) | lower tail too often | forecasts too high (bias) |
| sloped (mass near 1) | upper tail too often | forecasts too low (bias) |
Calibration is necessary but not sufficient. The climatological forecast (always the long-run distribution) is calibrated, because the outcomes really come from that distribution on average. But it uses no information, so it is not useful. Sharpness is a property of the forecasts alone: the width of their intervals (or the spread of ). The paradigm of Gneiting, Balabdaoui and Raftery (2007) is: maximise sharpness subject to calibration. This answers question 2 of section 1: both forecasts are calibrated, but forecast B is sharper (if it uses real information) and therefore better. A proper scoring rule such as the CRPS (next section) sees the difference.
Discrete outcomes and a flat PIT that hides problems
For counts, jumps, and is not uniform even for the true distribution. Use the randomised PIT with uniform on , or the non-randomised version of Czado, Gneiting and Held (2009). Also note that a flat histogram over all times can hide errors that cancel: too narrow in winter and too wide in summer gives a flat total histogram (Hamill, 2001). Check the PIT in subgroups (season, horizon, level of the series) as well.
3.4 Proper scoring rules and the CRPS #
A scoring rule gives a number (lower is better here) to a forecast when happens. It is proper if, when really comes from , the expected score is smallest at ; strictly proper if is the only minimiser. A proper score cannot be gamed: the best strategy is to report what you really believe. Coverage alone is not a score of this kind: an interval of infinite width always has perfect coverage.
Definition. The continuous ranked probability score is
It compares the forecast CDF with the "CDF" of the outcome, a step from 0 to 1 at . It is in the units of , and it is strictly proper for distributions with a finite mean (Gneiting and Raftery, 2007).
Move , and , or pick a preset. The orange curve is the forecast CDF, the blue step is the outcome. The lower panel shows the squared gap; its magenta area is the CRPS. The readouts give the area, the closed form and the kernel form: they agree. Notice: sharp and wrong costs about , and as the CRPS becomes the absolute error of a point forecast. Wide is never far wrong but still pays for its width.
Three equivalent forms. For with a finite mean:
(1) Integral (threshold) form: the definition above.
(2) Kernel form (Gneiting and Raftery, 2007): with independent draws from ,
The first term rewards forecasts close to ; the second term rewards spread, so a forecast does not gain by collapsing to a point. For an ensemble or a set of sample paths , replace the expectations by means over the members.
(3) Quantile form: the CRPS is twice the pinball loss, averaged over all levels:
Proof of the quantile form
Assume is continuous and strictly increasing, so .
- For a fixed , . Check: if the integrand is and the integral is ; if the integral is . Both agree with the definition.
- Put and integrate over : .
- Swap the order of integration (Fubini). For , the point lies between and exactly when ; it contributes .
- For , the point lies between and exactly when ; the integral runs from right to left, so it contributes .
- Multiply by 2 and add: . This is the integral of : the CRPS.
Two special cases.
- Point forecast. If is a step at , then between and and 0 elsewhere, so . The CRPS generalises the absolute error, and you can compare a probabilistic forecast with a point forecast on the same scale.
- Gaussian forecast , with , the standard normal CDF and its density (Gneiting et al., 2005):
Even a perfect mean () gives : the price of the uncertainty.
In practice: a finite set of quantiles. Many models output only quantiles. The quantile form suggests the approximation for evenly spaced levels. Summed over a test set and divided by , this is the weighted quantile loss (WQL) used, for example, with to evaluate Chronos (Ansari et al., 2024) and in the GIFT-Eval benchmark (Aksu et al., 2024). Epidemic forecast hubs use the closely related weighted interval score (Bracher et al., 2021).
A point forecast says , and the outcome is . What is the CRPS of this forecast?
A point forecast is a CDF that jumps from 0 to 1 at . The outcome is a step at 7. The two steps differ by 1 on and agree elsewhere, so the integral of the squared gap is the length 2. The CRPS of a point forecast is its absolute error.
3.5 Split conformal prediction #
The intervals so far come from a model. If the model is wrong, the coverage is wrong. Conformal prediction builds intervals around any point forecaster from its errors on held-out data, with a coverage guarantee that does not need a correct model (Vovk, Gammerman and Shafer, 2005; Angelopoulos and Bates, 2021).
Split conformal for regression. You have a fitted point forecaster and a calibration set of new pairs that were not used to fit it.
- Compute the nonconformity scores , .
- Set . If , let be the -th smallest score; if , set .
- For a new case, report the interval .
Exchangeability. Random variables are exchangeable if their joint distribution does not change when you permute them. I.i.d. data are exchangeable; a time series with autocorrelation or a trend is not.
Theorem (split conformal coverage). If the calibration scores and the test score are exchangeable, then
If the scores have no ties (for example, continuous data), the coverage is also below .
Proof.
- is in the interval exactly when .
- Assume no ties. Let be the rank of among all scores (1 = smallest). By exchangeability, every rank from 1 to has the same probability .
- (the -th smallest calibration score) means that fewer than calibration scores are below , that is .
- So the coverage is . Since , this is ; since , it is .
- With ties, also holds in some cases with , so the coverage can only grow.
Answer to question 3 of section 1. With and : . Use the 18th smallest error. The coverage is exactly for continuous exchangeable data. The 17th would give only .
Move and , then switch the noise. The blue series is the "monthly demand" series; the orange line is a least-squares forecast (trend and one yearly sine wave) fitted on (left of the dashed line). The scores come from the aqua calibration window just before the yellow origin; the band is on the 40 test months. Magenta points fall outside. With constant noise the test coverage stays near the guarantee (press New noise to see it vary). With jumps after t = 80, the calibration errors no longer look like the test errors, and the coverage collapses. For small and small , and the band is infinite.
What the guarantee says, and what it does not.
- It is marginal: an average over calibration sets and test cases. A single calibration set gives a coverage that varies around (the variation shrinks like ).
- It is not conditional: a 90 % interval can cover 99 % in summer and 70 % in winter and still be 90 % on average. With a constant width, the interval is too wide where the noise is small and too narrow where it is large.
- Conformalized quantile regression (CQR; Romano, Patterson and Candès, 2019) gives intervals whose width changes with . Fit quantile models and ; use the scores ; report . The same theorem gives coverage .
- The calibration set must not be used to fit the model. Training residuals are too small, and the intervals then under-cover.
Why time series break exchangeability. Calibration errors come from the past and the test error from the future. (1) Errors are autocorrelated: a run of large errors in the calibration window makes all of them similar, so the window is effectively smaller than . (2) The series drifts: the level, the noise or the model quality change, as in the widget. (3) Errors at horizon are larger than at horizon 1, so scores must come from the same horizon. The theorem then gives no guarantee, though the method often still works reasonably when the changes are slow.
You have calibration scores and want a split conformal interval with . Which score do you use as the half-width?
. The coverage is then for continuous exchangeable data. The plain empirical quantile of the scores uses instead of and gives slightly too little coverage; the largest score gives , more than needed.
3.6 Conformal methods for time series #
Practical recipe. Run a rolling-origin backtest (lesson 03). For each horizon , keep the absolute -step errors of the last origins as the calibration scores, and recompute at each new origin. The window follows slow changes; the guarantee is only approximate.
Adaptive conformal inference (ACI; Gibbs and Candès, 2021) adds feedback. It keeps a working level and changes it after each outcome:
- Build the interval with the conformal recipe at level (for example, the -th smallest of the last scores). If , the interval is the whole line; if , it is empty.
- Observe and set if , else 0.
- Update the level with a step size :
After a miss, drops by and the next interval is wider; after a hit, rises by and the next interval is a little narrower.
Theorem (long-run coverage of ACI; Gibbs and Candès, 2021). For any sequence of data (no assumption at all) and ,
Proof.
- stays in . One step changes by at most . If , the interval is the whole line, so and increases. If , the interval is empty, so and decreases. So can leave by at most one step.
- Telescoping. Summing the update over gives .
- Divide by : .
- By step 1, .
Move , then change the scenario. The top panel shows 400 forecast errors after an initial calibration period of 100. The orange band is ACI on the last 100 scores; the dashed lines are static split conformal from the first 100 scores. At the yellow line the noise triples. The middle panel shows ; the bottom panel shows the coverage over the last 50 steps. Notice: static conformal drops to about 35 % coverage and never recovers; ACI dips briefly and returns to 90 %. With , ACI becomes split conformal on a rolling window and recovers only after the window has refilled.
What ACI does not promise. The guarantee is about the long-run average of misses. It says nothing about coverage at a given time, in a given season, or conditional on anything. The interval can be infinite for a few steps (when ). A large reacts fast but makes the width jumpy; a small is smooth but slow. Later methods choose online or combine several values.
Two related methods, in short.
- EnbPI (Xu and Xie, 2021) fits an ensemble of models on bootstrap samples of the training data. The out-of-bag residuals are the scores, and the newest residuals replace the oldest ones as data arrive. It has an approximate guarantee when the errors are stationary and the model is consistent.
- Conformal PID control (Angelopoulos, Candès and Tibshirani, 2023) updates the quantile directly, (the "P" part, a quantile tracker), and adds an integral term and an optional forecast of the next score ("scorecaster"), as in a PID controller. It has the same kind of long-run guarantee.
A conformal 90 % interval method covers 90 % of the outcomes over a whole year, but only 60 % in winter. Is its guarantee broken?
Split conformal promises coverage on average over calibration sets and test cases; ACI promises a long-run average of misses. Neither promises coverage conditional on a subgroup such as winter. To get better coverage per season, calibrate per season (with fewer scores) or use scores that scale with the local noise (CQR or a model of the variance).
3.7 Many horizons and sample paths #
A forecast for each horizon is not enough for a question about several horizons. Let be the errors of two days, each and independent. The 90 % quantile of each is . The 90 % quantile of the two-day total error is , not . The quantile of a sum is not the sum of the quantiles; they agree only when the errors are perfectly correlated. With positive correlation, the truth is between the two numbers.
So for weekly totals, maxima over a day, or "the first time the stock runs out", use sample paths: simulate many futures , compute the quantity on each path, and take its empirical quantiles. Paths come from a model (simulate the future shocks of an ARIMA or ETS model, or resample past residuals: a bootstrap) or from a generative network such as DeepAR (lesson 09). Score them with the sample CRPS (kernel form) per horizon, or with a multivariate score such as the energy score.
4. Worked example #
(a) A quantile from the pinball loss. Data , . The mean pinball loss at : the outcomes 2, 4, 5 are below and cost ; the outcome 12 is above and costs :
In the same way and . The slope just left of 7 is minus , negative; just right of 7 it is , positive. So is the minimiser. It is the 4th smallest value, since .
(b) The CRPS three ways. Forecast , outcome . Then , , and . The three terms in the bracket are , and :
The kernel form gives , and the integral of over gives too (section 5 checks all three). For comparison, the absolute error of the median forecast is : the spread of the forecast lowers the score because the outcome was close to the centre.
(c) A split conformal interval. The absolute errors of 9 calibration months are . For :
- .
- Sorted: . The 8th smallest is .
- If the next point forecast is , the 80 % interval is .
- For exchangeable data the coverage is exactly .
(d) Two steps of ACI. , , .
- The outcome falls outside: , so . The next interval uses the -th score: it is wider.
- Had it fallen inside: , slightly narrower.
Nine hits move up by , and one miss moves it down by : at a miss rate of exactly 10 %, stays where it is.
5. In code #
NumPy and SciPy check the worked example; the notebook adds quantile gradient boosting and ACI.
import numpy as np
from scipy.stats import norm
def pinball(y, q, tau):
u = y - q
return np.maximum(tau * u, (tau - 1) * u)
# (a) the empirical minimiser of the mean pinball loss is a sample quantile
y = np.array([2., 4., 5., 7., 12.])
grid = np.linspace(0, 14, 1401)
L = [pinball(y, q, 0.7).mean() for q in grid]
print(grid[np.argmin(L)], np.quantile(y, 0.7, method="inverted_cdf")) # 7.0 7.0
# (b) CRPS of N(0.3, 1.5^2) at y = 1, three ways
mu, s, yo = 0.3, 1.5, 1.0
z = (yo - mu) / s
closed = s * (z * (2 * norm.cdf(z) - 1) + 2 * norm.pdf(z) - 1 / np.sqrt(np.pi))
x = np.linspace(-15, 15, 300001)
integral = np.trapezoid((norm.cdf(x, mu, s) - (x >= yo)) ** 2, x)
taus = (np.arange(10000) + 0.5) / 10000
quant = 2 * pinball(yo, norm.ppf(taus, mu, s), taus).mean()
print(round(closed, 4), round(integral, 4), round(quant, 4)) # 0.4785 0.4785 0.4785
# (c) split conformal half-width
res = np.array([0.4, 1.1, 0.7, 2.3, 0.2, 1.6, 0.9, 3.0, 1.3])
n, alpha = len(res), 0.2
k = int(np.ceil((n + 1) * (1 - alpha)))
print(k, np.sort(res)[k - 1]) # 8 2.3
# (d) its coverage over many exchangeable data sets is k/(n+1) = 0.8
rng = np.random.default_rng(0)
scores = np.abs(rng.normal(size=(200000, n + 1))) # n calibration scores + 1 test score
qhat = np.sort(scores[:, :n], axis=1)[:, k - 1]
print(round(np.mean(scores[:, n] <= qhat), 3)) # 0.801, close to k/(n+1) = 0.8
np.trapezoid needs NumPy 2.0 or newer (older versions call it np.trapz).
6. Where it shows up #
- Retail and supply chains. Stock levels are quantiles at the critical ratio. The M5 uncertainty competition (Makridakis et al., 2022) asked for nine quantiles of Walmart sales and scored them with a weighted scaled pinball loss. Many of the top teams used gradient-boosted trees (LightGBM) on lag features (lesson 08) with quantile losses.
- Energy. Load, wind and solar forecasts are quantile forecasts; the GEFCom2014 competition scored 99 quantiles with the pinball loss. Reserves and trading bids are set from upper quantiles.
- Weather and climate (ML for science). Ensemble forecasts are evaluated with the CRPS and with rank or PIT histograms. GenCast (Price et al., 2024), a diffusion model for global weather, reports the ensemble CRPS against the ECMWF ensemble.
- Epidemiology. The US COVID-19 Forecast Hub collected 23 quantiles per forecast and scored them with the weighted interval score, a quantile approximation of the CRPS (Bracher et al., 2021).
- Foundation models. Chronos, Chronos-Bolt, TimesFM and Moirai give quantiles or samples (lesson 09). Check their coverage on your own data with a backtest, and wrap them with conformal intervals if it is wrong.
- Software. Conformal intervals for forecasts exist in common libraries (for example MAPIE, and the
conformal intervals of Nixtla's
statsforecastandmlforecast). Read what the calibration set is: the guarantee depends on it.
7. Common mistakes #
- Judging intervals by coverage only. A very wide interval always covers. Report coverage and width, or use a proper score (CRPS, pinball loss, interval score).
- Trusting model intervals without a backtest. ARIMA and ETS intervals assume a correct model; check their empirical coverage over many origins.
- Adding quantiles over horizons. The 90 % quantile of a weekly total is not the sum of the daily 90 % quantiles. Use sample paths.
- Calibrating on training residuals. In-sample errors are too small, so the interval is too narrow. The calibration data must be new to the model.
- Shuffling time series before conformal calibration. Random splits mix future and past (leakage) and hide the drift. Calibrate on the most recent past and test on the future.
- Using
np.quantile(scores, 1 - alpha)instead of the -th smallest score. The difference is small for large , but the guarantee needs the . - Ignoring quantile crossing. Sort the predicted quantiles, or use a monotone parametrisation.
- Confusing the two meanings of . In this lesson is the miscoverage, not the smoothing parameter.
8. Check yourself #
- Show that the pinball loss at is half the absolute error, and say which constant forecast
minimises its mean.
Answer
For , ; for , . So . The mean is minimised by the median (the 0.5-quantile), as for the absolute error. - An unsold newspaper costs 0.2 and a missing one costs 0.6. Which quantile of demand should you stock?
Answer
: the 75 % quantile. - The forecast is and the outcome is . Compute the CRPS.
Answer
, so . Even a perfect mean has a positive CRPS, about . - Why is a forecast that always gives the long-run distribution calibrated, and why is it still poor?
Answer
The outcomes really come from the long-run distribution on average, so the PIT values are uniform and every interval has the right coverage. But it uses no current information, so its intervals are as wide as possible. A proper score such as the CRPS rewards a forecast that is calibrated *and* sharp. - You have calibration scores. What is the smallest for which split conformal gives a finite interval?
Answer
We need , so , that is . For the interval is infinite. - In ACI with and , the method misses 5 times in a row. How much has changed?
Answer
Each miss changes by , so five misses lower it by : from 0.1 to 0.055. The intervals become wider.
Define the pinball loss for the error .
if and if ; equivalently .
Which constant minimises the expected pinball loss , and why?
The -quantile of . The derivative of the expected loss is , which is zero where .
What is the best stock level when an unsold unit costs and a missing unit costs ?
The quantile of demand at the critical ratio .
What is the PIT value of a forecast , and what should its histogram look like?
. For calibrated forecasts the are uniform on , so the histogram is flat.
What does a U-shaped PIT histogram mean?
Too many outcomes fall in the tails: the forecast distributions are too narrow (over-confident), and intervals under-cover.
What is the difference between calibration and sharpness?
Calibration: forecast probabilities match observed frequencies (a joint property of forecasts and outcomes). Sharpness: the forecasts are concentrated (narrow intervals); it depends on the forecasts only.
Give the definition and the kernel form of the CRPS.
, with independent draws from .
How is the CRPS related to the pinball loss?
: twice the pinball loss averaged over all levels.
In split conformal with calibration scores and miscoverage , which score is the half-width?
The -th smallest score (infinite if this index is larger than ).
Write the update rule of adaptive conformal inference.
, where if was outside the interval at level .
9. Interview angle #
- "How do you get prediction intervals from a gradient-boosting forecaster?" — Train two more models with the quantile loss (for example and ), sort the outputs to avoid crossing, and check the coverage in a rolling-origin backtest. Or keep the point model and add conformal intervals from recent backtest errors, one set of scores per horizon; use CQR to combine both.
- "Why does the pinball loss give a quantile?" — Derivative : a step up costs for the outcomes below and saves for those above; the balance point has a share below.
- "How would you evaluate a probabilistic forecast?" — Calibration (coverage of several intervals, PIT histogram, also per subgroup) and a proper score (CRPS or the mean pinball loss over quantiles, scaled across series); compare with a seasonal naive forecast with bootstrapped intervals.
- "What does conformal prediction guarantee, and what breaks it for time series?" — Marginal coverage under exchangeability; dependence and drift break it; ACI restores a long-run average guarantee for any sequence, but not coverage at each time.
10. Practice #
The notebook for this lesson runs in Colab or in the browser. It has five exercises, each with a check cell and a folded solution:
- Write
pinball(y, q, tau)and check that its empirical minimiser over a grid is the sample quantile. - Write
crps_gaussian(mu, sigma, y)and compare it with the sample kernel form and with twice the mean pinball loss over a grid of levels. - Train
HistGradientBoostingRegressor(loss="quantile")on lag features for and measure the coverage of the 80 % interval on a test period. - Write
split_conformal(cal_scores, alpha)and check its coverage over 2000 simulated exchangeable data sets (between and ). - Write
adaptive_conformal(scores, alpha, gamma)and compare its coverage after a variance jump with static split conformal.
11. Watch and read #
- Hyndman and Athanasopoulos, Forecasting: Principles and Practice, 3rd ed., §5.5 distributional forecasts and prediction intervals and §5.9 evaluating distributional forecast accuracy (quantile scores, Winkler score, CRPS).
- Gneiting and Raftery (2007), Strictly proper scoring rules, prediction, and estimation, JASA 102: the CRPS, its kernel form and proper scores (author PDF).
- Gneiting and Katzfuss (2014), Probabilistic forecasting, Annual Review of Statistics and Its Application 1: calibration, sharpness and the PIT.
- Angelopoulos and Bates, A Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty Quantification (arXiv 2107.07511): split conformal, CQR, and the proofs.
- Gibbs and Candès (2021), Adaptive conformal inference under distribution shift (NeurIPS): ACI and the long-run guarantee.
- Romano, Patterson and Candès (2019), Conformalized quantile regression.
- Xu and Xie (2021), Conformal prediction interval for dynamic time-series (ICML; extended arXiv version Conformal prediction for time series): EnbPI; Angelopoulos, Candès and Tibshirani (2023), Conformal PID control for time series prediction.
- Koenker and Bassett (1978), Regression quantiles, Econometrica 46: the origin of quantile regression.
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.
No Google account needed: Python runs inside your browser. The first start downloads about 40 MB; your changes are saved in this browser only.