Forecasting in eCommerce: demand, stock, cash and revenue, and how far to trust it

TL;DR

Difficulty: Advanced

A shop forecast exists to make a decision: what to reorder, how much seasonal stock to buy, whether the cash holds.

  • Forecast at the level the decision is made, and forecast demand, not sales: correct for the days a product was sold out.
  • Start from an event aligned seasonal naive baseline, then smoothing with a seasonal decomposition, regression or gradient boosting for promotions, Croston for the long tail, and reconcile the levels.
  • Score on unseen weeks with WAPE and MASE, never MAPE, and check that an 80% interval holds 80% of outcomes.
  • Turn it into decisions: reorder points from forecast error and service level, a newsvendor order for Christmas, revenue from new customers plus cohorts, and a cash forecast that shows the VAT month early.

Every shop owner forecasts, usually in their head: how many lamps for Christmas, when to reorder the mug that keeps selling out, whether February will be tight. This chapter builds those forecasts properly from a shop's own orders and stock, shows which methods work at which level, how to score them honestly, and how to turn a forecast with a range into a reorder point, a seasonal order and a cash plan.

A forecast is there to make a decision, not to be right

"How many Christmas lamps should I order in August? When do I reorder the mug that keeps selling out? Will there be enough money in the bank in February?" Those are the questions a shop owner actually asks. None of them is "what will sales be". Each one is a decision with a deadline, and a forecast is only useful if it makes that decision better.

That changes how you build one. A stock forecast is per product, for the weeks until the next delivery, with an honest range. A cash forecast is in money, by month, with the dates bills fall due. Same shop, same data, different forecasts.

This chapter is the shop specific part of a topic I have written about before. The general methods (moving averages, ARIMA, Prophet, judgement) are explained in forecasting for business, the regression view of a weekly series with autocorrelation in forecasting demand: autocorrelation and seasonality, and how to draw and present a forecast in communicating forecasts. Here I go further on what is particular to a shop: censored demand, thousands of products, slow sellers, levels that must add up, honest accuracy at low volumes, safety stock, the one shot Christmas order, and revenue and cash from your own orders. The reference book underneath most of it is Hyndman and Athanasopoulos, Forecasting: Principles and Practice, third edition, free online1.

Example: the three decisions at Wrenfield Home

Wrenfield Home is the invented example shop of this series: an online homeware shop in Leeds at wrenfieldhome.example, run by Priya, with Callum as her developer. It sells ceramics, kitchen textiles, lamps and small furniture, about 1,400 products. The example's baseline: 110,000 sessions a month, a conversion rate of 1.8%, about 1,980 orders a month (1,300 of them from new customers), an average order value of £72 including VAT, a gross margin of 52%, a return rate of 9% and £14,000 a month on Google and Meta ads.

In late summer 2026 Priya writes down three decisions she has to make:

  • Stock, every week: when to reorder each of the 140 products that bring most of the revenue, and how many to keep in reserve. The best seller, the Hebden stoneware mug, ran out twice last year.
  • Seasonal stock, once: how many Fenwick star lamps to order from the supplier before Christmas. There is one order, placed in August, and no second chance.
  • Cash, every month: whether February 2027 is safe, with the Christmas VAT bill and the spring stock both falling due.

Choose the level: total, category or product, and week or day

A shop's sales form a hierarchy: the total splits into categories, categories into products, products into variants (a colour, a size). Time forms a second one: days, weeks, months. The right level is the one at which the decision is made. A reorder is a product decision taken weekly, a packing room rota a total by day, a cash plan a total by month.

The catch is noise. The fewer sales a series has, the more of what you see is chance. A useful rule of thumb comes from the Poisson distribution, the standard model for counts of independent events such as orders (see Foundations: distributions). For a Poisson count, the typical random wobble relative to the average is:

CV=σμ=1λCV = \frac{\sigma}{\mu} = \frac{1}{\sqrt{\lambda}}

where CVCV is the coefficient of variation (the standard deviation as a share of the average), σ\sigma is the standard deviation of weekly sales, μ\mu is the average weekly sales, and λ\lambda is the average number of units a week, which for a Poisson count equals both μ\mu and σ2\sigma^2. Real sales are usually noisier than Poisson, never quieter, so this is the floor of the noise, not the ceiling.

Example: how noisy each level is at Wrenfield Home

Wrenfield Home sells about 731 units a week in total (1,980 orders a month, about 457 a week, at 1.6 units an order). Working the formula through at each level:

  • Total, 731 units a week: 1÷731=0.0371 \div \sqrt{731} = 0.037, so at least 3.7% of pure chance.
  • Ceramics, 330 units a week: 1÷330=0.0551 \div \sqrt{330} = 0.055, so 5.5%.
  • The Hebden mug, 38 a week: 1÷38=0.1621 \div \sqrt{38} = 0.162, so 16.2%.
  • A typical lamp, 4 a week: 1÷4=0.51 \div \sqrt{4} = 0.5, so 50%.
  • A long tail sideboard, one sale every two weeks, 0.5 a week: 1÷0.5=1.4141 \div \sqrt{0.5} = 1.414, so 141%.
Bar chart of the minimum random noise in weekly sales, as a coefficient of variation, at five levels of Wrenfield Home's hierarchy, invented example based on the Poisson rule one divided by the square root of the weekly average. Total shop, 731 units a week: 3.7%. Ceramics, 330 a week: 5.5%. Hebden mug, 38 a week: 16.2%. A typical lamp, 4 a week: 50%. A long tail sideboard, 0.5 a week: 141.4%. Tap or click to open full screen and move around

The total can be forecast to within a few per cent. A single sideboard cannot be forecast week by week, however clever the model. For the sideboard the right question is "how many to keep so that I rarely miss a sale", the safety stock question later in this chapter. Choosing the level is the first modelling decision, made before any model.

Demand is not sales: a sold out product hides its demand

The order table records sales: what people bought. A forecast for stock needs demand: what people would have bought if the product had been there. The two are the same only while the product is in stock. On the days it is sold out, sales are zero or close to it, and the true demand is hidden. Statisticians call such data censored: you see a value only up to a limit, here the stock you had.

Feed censored sales into a model and it learns that the product sells less than it does. You order less, run out again, record even lower sales, and the forecast spirals down. Best sellers are hit hardest, because they run out.

The fix has three parts. First, record for every product and every day whether it was in stock. Second, estimate the demand on the sold out days from the selling rate on the days it was available. Third, train the model on that demand, or at least exclude the sold out days from training. For a simple estimate, see Foundations: ratios and rates:

D^=S+Sdin×dout\hat{D} = S + \frac{S}{d_{\text{in}}} \times d_{\text{out}}

where D^\hat{D} is the estimated demand for the period, SS is the units actually sold, dind_{\text{in}} is the number of days the product was in stock, and doutd_{\text{out}} is the number of days it was sold out. The fraction S÷dinS \div d_{\text{in}} is the daily selling rate while it was available.

Example: the Hebden mug in moss glaze

Over four weeks in October 2025 (28 days), the Hebden mug in moss glaze sold 96 units. It was sold out for nine of those days, so it was in stock for 19.

  • Daily rate while in stock: 96÷19=5.0596 \div 19 = 5.05 units.
  • Hidden demand on the nine sold out days: 5.05×9=45.55.05 \times 9 = 45.5 units.
  • Estimated demand: 96+45.5=141.596 + 45.5 = 141.5 units.

The order table says 96. The demand was about 141. Sales understated demand by 45.5÷141.5=32%45.5 \div 141.5 = 32\%. A forecast trained on the 96 would have ordered a third too little for the next autumn. One caveat keeps this honest: some customers who found the moss glaze sold out bought the sage glaze instead, so part of the hidden demand shows up elsewhere. The estimate is a correction, not a measurement.

Building the weekly demand series from a Solidus shop

On a shop built on Ruby on Rails and Solidus, everything the forecast needs is already in your own database. Sales come from spree_orders and spree_line_items. Stock history comes from spree_stock_movements: every change to a product's stock (a shipment, a delivery from the supplier, a return put back on the shelf) is a row with the stock item, the quantity (negative for stock going out) and the time, and each spree_stock_items row ties a variant to a stock location2. Adding up the movements day by day gives the stock level at the end of each day.

One caution from the Solidus source: creating a stock movement adjusts the stock count, but the method set_count_on_hand writes a new count directly without creating a movement3. If someone corrects stock that way, the running sum drifts. Check the reconstruction against today's count_on_hand for each product before you trust it, and record stock counts as movements from then on.

-- Weekly units sold per variant, and the days each variant was in stock
WITH sales AS (
  SELECT li.variant_id,
         date_trunc('week', (o.completed_at AT TIME ZONE 'UTC') AT TIME ZONE 'Europe/London') AS week,
         sum(li.quantity) AS units
  FROM spree_line_items li
  JOIN spree_orders o ON o.id = li.order_id
  WHERE o.completed_at IS NOT NULL
    AND o.state <> 'canceled'
  GROUP BY 1, 2
),
moves AS (
  SELECT si.variant_id,
         ((sm.created_at AT TIME ZONE 'UTC') AT TIME ZONE 'Europe/London')::date AS day,
         sum(sm.quantity) AS change
  FROM spree_stock_movements sm
  JOIN spree_stock_items si ON si.id = sm.stock_item_id
  WHERE si.deleted_at IS NULL
  GROUP BY 1, 2
),
days AS (
  SELECT v.id AS variant_id, d::date AS day
  FROM spree_variants v
  CROSS JOIN generate_series(
    (SELECT min(day) FROM moves), current_date - 1, interval '1 day') AS d
  WHERE v.deleted_at IS NULL
    AND v.track_inventory
),
levels AS (
  SELECT days.variant_id, days.day,
         sum(coalesce(m.change, 0))
           OVER (PARTITION BY days.variant_id ORDER BY days.day) AS stock_at_close
  FROM days
  LEFT JOIN moves m ON m.variant_id = days.variant_id AND m.day = days.day
),
weekly_stock AS (
  SELECT variant_id, date_trunc('week', day) AS week,
         count(*) FILTER (WHERE stock_at_close > 0) AS days_in_stock
  FROM levels
  GROUP BY 1, 2
)
SELECT w.variant_id,
       w.week::date AS week,
       coalesce(s.units, 0) AS units,
       w.days_in_stock
FROM weekly_stock w
LEFT JOIN sales s ON s.variant_id = w.variant_id AND s.week = w.week
ORDER BY 1, 2;

How it works, step by step:

  • sales adds up the units of every placed, uncancelled order per variant and week, in London time, because Rails stores times in UTC. date_trunc('week', ...) starts weeks on a Monday4.
  • moves adds up the stock movements per variant and day, and days builds one row per variant and calendar day, so quiet days still exist.
  • levels turns the daily changes into a stock level with a running sum, and weekly_stock counts the days that ended with stock above zero.

The demand column is then the sales scaled up by the in stock share of the week, using the formula above, and a week with no day in stock is marked as missing, not zero. A day that ended at zero counts as sold out even if the product sold out at 9pm, a simplification that a nightly stock snapshot removes later.

Example: what the query returns for the mug

For the moss mug in the week starting 13 October 2025 the query returns units = 21 and days_in_stock = 3, so the demand estimate is 21÷3×7=4921 \div 3 \times 7 = 49 units. The next week returns 0 and 0, and goes into the model as missing, not as a week nobody wanted the mug.

Start with the baselines, because they are hard to beat

A baseline is the simplest forecast that could work, and every model has to beat it. The two that matter for a shop are the naive forecast, which says next week equals last week, and the seasonal naive forecast, which says next week equals the same week last year5. Two things are worth adding for a shop.

First, baselines are humbling. The M5 competition asked thousands of teams to forecast 42,840 daily sales series from Walmart, from single products in single stores up to the total. Of the teams, 48.4% beat the naive forecast, 35.8% beat the seasonal naive, and only 7.5% beat the best benchmark, plain exponential smoothing on every product with the results added up6. Most clever submissions lost to exponential smoothing, a method first proposed in the late 1950s7.

Second, the shop calendar does not line up with week numbers. Black Friday 2025 fell on 28 November, in ISO week 48. Black Friday 2026 falls on 27 November, also week 48. Black Friday 2027 falls on 26 November, in week 47. A seasonal naive forecast by week number puts the 2027 peak a week late. Easter moves by up to five weeks. And some years have 53 ISO weeks, because a year is 52.18 weeks on average8. So align by event, not by week number: keep a calendar table of the dates that move (Black Friday, Easter, bank holidays, your own sale dates) and compare like with like.

Example: the baseline for the Black Friday week of 2027

Callum's seasonal naive forecast for ISO week 47 of 2027 copies week 47 of 2026: about 1,010 units, a normal busy pre peak week. The real Black Friday of 2027 is in week 47, so the forecast is about 700 units too low for that week and about 700 too high for week 48. Aligning by event (the Black Friday week copies the Black Friday week) fixes it with one join on the calendar table.

Exponential smoothing: the workhorse for totals and categories

Exponential smoothing forecasts with a weighted average of the past, in which recent weeks count most and older weeks count less and less. Its simplest form needs one number, the smoothing weight, and adapts to a level that drifts7. See Foundations: mean for weighted averages:

y^t+1=α yt+(1−α) y^t\hat{y}_{t+1} = \alpha\, y_t + (1 - \alpha)\, \hat{y}_t

where y^t+1\hat{y}_{t+1} is the forecast for next week, yty_t is what actually happened this week, y^t\hat{y}_t is what had been forecast for this week, and α\alpha is the smoothing weight between 0 and 1. A high α\alpha follows the latest week closely, a low one is calmer.

The full family adds a trend and a season, and the ETS framework (error, trend, season) chooses the combination automatically by fitting each and keeping the one with the best information criterion. One practical limit matters for a shop with weekly data. A seasonal model needs one seasonal value per period, and 52 of them is too many to estimate well. Forecasting: Principles and Practice recommends splitting off the season first with a decomposition (STL) and forecasting the rest with non seasonal smoothing8, and the statsforecast library refuses a seasonal ETS model when the season is longer than 24 periods9. Its MSTL model does exactly the recommended split.

Example: smoothing the lamp category

The lamp category's last three weeks were 120, 132 and 126 units, and the forecast going into the first of those weeks was 118. With α=0.3\alpha = 0.3:

  • After week 1: 0.3×120+0.7×118=118.60.3 \times 120 + 0.7 \times 118 = 118.6.
  • After week 2: 0.3×132+0.7×118.6=122.620.3 \times 132 + 0.7 \times 118.6 = 122.62.
  • After week 3: 0.3×126+0.7×122.62=123.630.3 \times 126 + 0.7 \times 122.62 = 123.63.

The forecast for next week is about 124 lamps. The jump to 132 moved it by only four units, because one busy week is weak evidence. The seasonal part, added back on top, lifts it towards Christmas.

Regression: add the promotions and holidays you know about

Smoothing only looks at the series' own past. A shop also knows the future: a sale planned for March, a newsletter feature, a bank holiday weekend. Regression adds them as explanatory variables, usually as dummy variables that are 1 in an affected week and 0 otherwise10. Modelling the logarithm of sales turns each effect into a percentage, which is how promotions behave. See Foundations: regression and Foundations: logarithms:

ln⁡yt=β0+β1Pt+β2Nt+β3Ht+β4Pt−1+st+εt\ln y_t = \beta_0 + \beta_1 P_t + \beta_2 N_t + \beta_3 H_t + \beta_4 P_{t-1} + s_t + \varepsilon_t

where yty_t is units sold in week tt, β0\beta_0 is the base level, PtP_t is 1 in a week with a sitewide promotion, NtN_t is 1 in a week the product line is featured in the newsletter, HtH_t is 1 in a week with a bank holiday weekend, Pt−1P_{t-1} is 1 in the week straight after a promotion, sts_t is the seasonal pattern, and εt\varepsilon_t is what the model cannot explain. Each coefficient β\beta turns into a multiplier through eβe^{\beta}.

The term Pt−1P_{t-1} is the one most shop models forget. A promotion pulls purchases forward, so the week after it is weaker than normal. Leave it out and the model credits the promotion with sales it merely moved. How price itself enters such a model, as an elasticity, is covered in modelling demand and price elasticity, and whether a promotion pays at all in the maths behind every discount.

Example: the March promotion for ceramics

Callum fits the model on three years of weekly ceramics demand. The coefficients come out as β1=0.41\beta_1 = 0.41 for a 20% sitewide promotion, β2=0.18\beta_2 = 0.18 for a newsletter feature, β3=−0.12\beta_3 = -0.12 for a bank holiday weekend, and β4=−0.08\beta_4 = -0.08 for the week after a promotion. As multipliers:

  • Promotion: e0.41=1.507e^{0.41} = 1.507, so 50.7% more units.
  • Newsletter feature: e0.18=1.197e^{0.18} = 1.197, so 19.7% more.
  • Bank holiday weekend: e−0.12=0.887e^{-0.12} = 0.887, so 11.3% fewer (people are out, not on the sofa with a phone).
  • Week after a promotion: e−0.08=0.923e^{-0.08} = 0.923, so 7.7% fewer.

The normal forecast for ceramics in the second week of March 2027 is 330 units. Priya plans the promotion and a newsletter feature in that week. The forecast becomes 330×e0.41+0.18=330×1.804=595330 \times e^{0.41 + 0.18} = 330 \times 1.804 = 595 units, and the week after drops to 330×0.923=305330 \times 0.923 = 305. Priya knows how many mugs the promotion needs, and that the week after will look weak without anything being wrong.

The long tail: products that sell now and then

At Wrenfield Home, 980 of the 1,400 products sell less than once a week, so their weekly series are mostly zeros. This is intermittent demand, and ordinary smoothing handles it badly: after each sale the forecast jumps up, then decays through the zero weeks, and it is never right.

Croston's method splits the series in two: the size of the demand when there is a sale, and the number of weeks between sales. It smooths each separately and divides one by the other11. See Foundations: ratios and rates:

y^=z^p^\hat{y} = \frac{\hat{z}}{\hat{p}}

where y^\hat{y} is the forecast demand per week, z^\hat{z} is the smoothed size of a sale when one happens, and p^\hat{p} is the smoothed number of weeks between sales. Forecasting: Principles and Practice is frank about its limits: the forecasts are biased, the method has no proper model behind it, and there is no formula for a prediction interval11. For the long tail that matters less than it sounds: what you need is a rate for the safety stock and a flag when the rate changes.

Example: the Ashby oak sideboard

Over the last 12 weeks the Ashby sideboard sold 0, 1, 0, 0, 2, 0, 0, 0, 1, 0, 1, 0. The sales happened in weeks 2, 5, 9 and 11, with sizes 1, 2, 1 and 1. To keep the arithmetic visible, this example uses plain averages where Croston's method would use smoothed values.

  • Average size of a sale: (1+2+1+1)÷4=1.25(1 + 2 + 1 + 1) \div 4 = 1.25 units.
  • Gaps between sales: 2 weeks (from the start to week 2), then 3, 4 and 2 weeks. Average gap: (2+3+4+2)÷4=2.75(2 + 3 + 4 + 2) \div 4 = 2.75 weeks.
  • Forecast rate: 1.25÷2.75=0.451.25 \div 2.75 = 0.45 units a week.

That is about one sideboard every two weeks, which is what goes into the reorder point. Nobody should read it as "0.45 sideboards next Tuesday".

Many products at once: gradient boosting

One smoothing model per product works, but it ignores what products share: the calendar, the promotions, the newsletter, the traffic. Gradient boosting fits one model across all products, a machine learning method that builds hundreds of small decision trees, each correcting the errors of the ones before. Each row of its training data is one product in one week, and the columns are features: last week's sales, sales a year ago, a rolling average, the price, whether a promotion runs, the category, the week of the year.

In the M5 competition most of the top methods used LightGBM, a fast gradient boosting library6. The same paper has the sobering detail: the top 50 methods beat the benchmark by about 40% at the total level, but by only about 3% at the level of single products in single stores6. A single product's weekly sales stay noisy, whatever you throw at them.

The library mlforecast wraps this in the same long format (unique_id, ds, y) as the statistical models, and future values of known features, such as a planned promotion, go in when you predict12.

import lightgbm as lgb
from mlforecast import MLForecast
from mlforecast.lag_transforms import RollingMean

fcst = MLForecast(
    models=[lgb.LGBMRegressor(random_state=0, verbosity=-1)],
    freq="W-MON",
    lags=[1, 52],
    lag_transforms={1: [RollingMean(window_size=4)]},
    date_features=["month"],
)
# weekly: unique_id, ds, y, plus promo, price and category per row
fcst.fit(weekly, static_features=["category"])
# future: the next 12 weeks of promo and price for every product
preds = fcst.predict(h=12, X_df=future)

Example: one row of the training data

For the Hebden mug in the week starting 1 March 2027, the row the model sees is:

FeatureValueWhere it comes from
Sales last week (lag 1)41the weekly demand series
Sales same week last year (lag 52)36the weekly demand series
Average of the last four weeks38.5rolling mean of lag 1
Price£14spree_prices for the variant
Promotion running0your promotions calendar
Categoryceramicsthe product's taxon
Month3the calendar

The target the model learns to predict is that week's demand. Because one model sees all 1,400 products, it learns from the 140 best sellers how a promotion lifts ceramics, and applies that to a new mug with only six weeks of history.

Make the levels add up: hierarchical reconciliation

Forecast each level separately and the category forecasts will not add up to the total forecast. The warehouse then plans to one number while the stock orders add up to another.

Making forecasts coherent, so that they add up the way the data does, is called reconciliation13. The simple options are:

  • Bottom up: forecast every product and add up. Nothing is lost through aggregation, but the noisy bottom level makes the totals noisy too.
  • Top down: forecast the total and split it by proportions. It is reliable at the top, but it cannot see what is particular to each product, and it is biased even when the total is not14.
  • Optimal reconciliation (MinT): forecast every level, then adjust them all together, giving more weight to the levels that have forecast well in the past. It is what the open source reconciliation libraries implement, and it usually beats both simple options13.

Top down with forecast proportions works like this (see Foundations: ratios and rates):

y~j=y^j∑ky^k×y^total\tilde{y}_j = \frac{\hat{y}_j}{\sum_k \hat{y}_k} \times \hat{y}_{\text{total}}

where y~j\tilde{y}_j is the reconciled forecast for category jj, y^j\hat{y}_j is that category's own forecast, ∑ky^k\sum_k \hat{y}_k is the sum of all category forecasts, and y^total\hat{y}_{\text{total}} is the forecast for the total.

Example: next week's categories at Wrenfield Home

The forecasts for the week starting 7 September 2026 are 760 units for the total, and 340 for ceramics, 205 for kitchen textiles, 130 for lamps and 50 for furniture. The categories add up to 725, so 35 units are missing between the levels.

  • Bottom up: the total becomes 725.
  • Top down: each category is scaled by 760÷725=1.0483760 \div 725 = 1.0483. Ceramics becomes 340×1.0483=356.4340 \times 1.0483 = 356.4, textiles 214.9214.9, lamps 136.3136.3, furniture 52.452.4, and they add up to 760.

Which is right? In Callum's backtest (next section) the total forecast was off by 7% on average, the categories added up by 9%. The total has the better record, so the top down version is the better starting point, and MinT would sit close to it.

Accuracy: MAE, WAPE and MASE, and why MAPE misleads

Score a forecast on weeks it never saw, with the right measure. The most popular one, the mean absolute percentage error (MAPE), is the wrong one for a shop with a long tail.

Three measures do the job (see Foundations: mean):

MAE=1n∑t=1n∣yt−y^t∣WAPE=∑t=1n∣yt−y^t∣∑t=1nytMASE=MAE1T−m∑t=m+1T∣yt−yt−m∣\text{MAE} = \frac{1}{n}\sum_{t=1}^{n} \lvert y_t - \hat{y}_t \rvert \qquad \text{WAPE} = \frac{\sum_{t=1}^{n} \lvert y_t - \hat{y}_t \rvert}{\sum_{t=1}^{n} y_t} \qquad \text{MASE} = \frac{\text{MAE}}{\frac{1}{T-m}\sum_{t=m+1}^{T} \lvert y_t - y_{t-m} \rvert}

where yty_t is the actual value in week tt, y^t\hat{y}_t the forecast, nn the number of test weeks, TT the number of training weeks, and mm the season length used for the scaling (52 for a weekly seasonal naive, 1 for a plain naive). The mean absolute error (MAE) is the average miss in units. The weighted absolute percentage error (WAPE) divides all the misses by all the sales, so it is a percentage that does not explode when a week has zero sales. The mean absolute scaled error (MASE), proposed by Hyndman and Koehler, divides the MAE by the error a naive forecast made on the training data: below 1 means better than naive15.

The MAPE averages the percentage error of each week. In a week with zero sales that percentage is infinite or undefined, and in weeks with small sales it is huge16. Tools that drop the zero weeks make it worse, because they ignore exactly the weeks where the forecast said "some" and the truth said "none". One more subtlety: a forecast that minimises the MAE aims at the median, not the average16. For a product that sells in fewer than half of all weeks, the median week is zero, so the MAE rewards forecasting zero, which is useless for stock.

The testing itself is time series cross validation: pick a cutoff, fit on everything before it, forecast the next weeks, score, move the cutoff forward and repeat. The book calls it evaluation on a rolling forecasting origin17.

Example: scoring the sideboard two ways

Over eight test weeks the sideboard sold 0, 2, 0, 1, 0, 0, 3, 0, so 6 units. Croston forecast 0.75 a week throughout.

  • Absolute errors: 0.75, 1.25, 0.75, 0.25, 0.75, 0.75, 2.25, 0.75. Sum: 7.5.
  • MAE: 7.5÷8=0.947.5 \div 8 = 0.94 units a week.
  • WAPE: 7.5÷6=125%7.5 \div 6 = 125\%.
  • MAPE: undefined, because five of the eight weeks have zero sales. Dropping them gives (1.25÷2+0.25÷1+2.25÷3)÷3=54%(1.25 \div 2 + 0.25 \div 1 + 2.25 \div 3) \div 3 = 54\%, a number that looks better than the WAPE and means nothing.
  • A forecast of zero every week: absolute errors add up to 6, so the MAE is 6÷8=0.756 \div 8 = 0.75, better than Croston's 0.94. Yet a shop that stocked zero sideboards would have lost all six sales.

At the sideboard's level, judge the forecast by what it does to stock (sales missed, stock left over), not by an error score. At higher levels the scores work, and Callum's backtest over 26 weekly cutoffs, with 12 weeks ahead each time, gives this WAPE by level (invented example figures):

LevelSeasonal naiveMSTL with smoothingLightGBM across products
Total14%8%7%
Category18%11%10%
A products (140 best sellers)38%29%27%
C products (980 slow sellers)120%96%94%

The pattern matches what the M5 competition found: large gains at the top, small gains at the bottom.

How far you can trust it: prediction intervals, checked

A prediction interval gives the range in which the actual value should fall with a stated probability. For a forecast with roughly normal errors (see Foundations: confidence intervals):

y^t+h±z σ^h\hat{y}_{t+h} \pm z \,\hat{\sigma}_h

where y^t+h\hat{y}_{t+h} is the forecast hh weeks ahead, σ^h\hat{\sigma}_h is the standard deviation of the forecast error at that horizon, and zz is the multiplier for the chosen probability, 1.28 for an 80% interval. The error grows with the horizon, so the interval widens the further ahead you look, which is the fan shape explained in communicating forecasts.

The model's own interval is a claim. Check it. In the backtest, count how often the actual landed inside the 80% interval. It should be about 80% of the time. If it is much less, the model is overconfident, usually because it does not know about the shocks your shop lives with (a supplier delay, a viral post, a site outage). Widen the interval by the factor that makes the backtest coverage right.

Example: the autumn forecast and its coverage check

Line chart of Wrenfield Home's total weekly units, invented example. Actual units from week 22 to week 35 of 2026 move between 662 and 741. The forecast from week 36 to week 49 rises from 752 to 1,010 in week 47, peaks at 1,720 in the Black Friday week 48 and falls to 1,050 in week 49. The 80% interval widens with the horizon, from 709 to 795 in week 36 to 1,362 to 2,078 in week 48. Tap or click to open full screen and move around

Callum checks the interval first. In the backtest of the previous 52 weeks, the actual total landed inside the model's 80% interval 37 times: 37÷52=71%37 \div 52 = 71\%. With 52 tries and a true rate of 80%, about 41 or 42 hits would be expected, with a typical wobble of about 3, so 37 is clearly short. He widens all intervals by 20% and the backtest gives 42 hits out of 52, 81%. The chart shows the widened band. For the Black Friday week, it says: plan for about 1,720 units, and do not be surprised by anything from about 1,360 to 2,080. Priya staffs the packing room for 1,900 and arranges two temps on call.

Safety stock and the reorder point

A reorder point is the stock level at which you order more. It has to cover the demand until the delivery arrives (the lead time), plus a reserve for the case that demand runs higher than forecast: the safety stock. The size of the reserve follows from the cycle service level, the probability of not running out before each delivery arrives18.

The standard formula (see Foundations: distributions):

s=μL+k σLσL=σwLs = \mu_L + k\, \sigma_L \qquad \sigma_L = \sigma_w \sqrt{L}

where ss is the reorder point in units, μL\mu_L is the forecast demand over the lead time, kk is the safety factor for the chosen service level, σL\sigma_L is the standard deviation of the forecast error over the lead time, σw\sigma_w is the standard deviation of the weekly forecast error, and LL is the lead time in weeks. The term k σLk\,\sigma_L is the safety stock. The square root comes from adding independent weekly errors: variances add, so standard deviations grow with the square root of the number of weeks18.

Two details make the difference in practice. First, σw\sigma_w is the error of your forecast, ideally its root mean square error from the backtest, not the raw spread of sales: the MIT supply chain course notes make exactly this point, and a better forecast therefore directly means less stock18. Second, the safety factor comes from the normal distribution: k=1.28k = 1.28 for 90%, k=1.65k = 1.65 for 95% and k=2.05k = 2.05 for 98%19.

When the supplier's lead time varies too, the uncertainty has a second source, and the standard deviation becomes19 (see Foundations: spread):

σL=Lˉ σw2+dˉ 2 σlead2\sigma_L = \sqrt{\bar{L}\, \sigma_w^2 + \bar{d}^{\,2}\, \sigma_{\text{lead}}^2}

where Lˉ\bar{L} is the average lead time in weeks, σw\sigma_w is the weekly forecast error as before, dˉ\bar{d} is the average weekly demand, and σlead\sigma_{\text{lead}} is the standard deviation of the lead time in weeks.

Example: the reorder point for the Hebden mug

The mug's forecast is 38 a week, the weekly forecast error from the backtest is 9 units, the potter in Stoke takes four weeks, and Priya wants a 95% cycle service level.

  • Demand over the lead time: μL=38×4=152\mu_L = 38 \times 4 = 152 units.
  • Error over the lead time: σL=9×4=18\sigma_L = 9 \times \sqrt{4} = 18 units.
  • Safety stock: 1.65×18=29.71.65 \times 18 = 29.7, so 30 mugs.
  • Reorder point: 152+30=182152 + 30 = 182 mugs.

Now suppose the potter's lead time is four weeks on average but varies with a standard deviation of one week:

  • σL=4×92+382×12=324+1,444=1,768=42.0\sigma_L = \sqrt{4 \times 9^2 + 38^2 \times 1^2} = \sqrt{324 + 1{,}444} = \sqrt{1{,}768} = 42.0 units.
  • Safety stock: 1.65×42.0=69.41.65 \times 42.0 = 69.4, so 70 mugs, and the reorder point is 152+70=222152 + 70 = 222.

An unreliable lead time more than doubles the safety stock, from 30 to 70 mugs. Most of the reserve now protects against the supplier, which is worth a conversation with the potter before a better model.

Service levels by product class: where the stock money goes

Every per cent of service level costs stock, and the cost rises steeply near 100%. One level for all 1,400 products ties up money where it matters least, so sort products into classes by revenue (an ABC analysis) and give each class its own target. Which products belong in which class is covered in product and category analytics.

Example: safety stock at Wrenfield Home, one level for all against tiered levels

Callum groups the products (invented example figures, lead times and errors per product):

ClassProductsWeekly forecast error per productLead timeService levelSafety stock per productUnit cost
A, top revenue1401.6 units4 weeks98%2.05×1.6×2=6.562.05 \times 1.6 \times 2 = 6.56£14
B, middle2800.9 units6 weeks95%1.65×0.9×2.449=3.641.65 \times 0.9 \times 2.449 = 3.64£16
C, long tail9800.35 units6 weeks90%1.28×0.35×2.449=1.101.28 \times 0.35 \times 2.449 = 1.10£20

Multiplying by the number of products and the unit cost gives the money tied up in safety stock:

  • A: 6.56×140×14=6.56 \times 140 \times 14 = £12,858.
  • B: 3.64×280×16=3.64 \times 280 \times 16 = £16,307.
  • C: 1.10×980×20=1.10 \times 980 \times 20 = £21,560.
  • Total, tiered: £50,725.

With 98% for every class, B and C need 2.05÷1.652.05 \div 1.65 and 2.05÷1.282.05 \div 1.28 times as much: B £20,260 and C £34,529, a total of £67,647. Tiering frees about £16,900, almost all of it from the long tail, while the products that bring most of the revenue keep the highest protection.

Grouped bar chart of the value of safety stock by product class at Wrenfield Home, invented example. With one 98% service level for all products: class A £12,858, class B £20,260, class C £34,529. With tiered levels of 98%, 95% and 90%: class A £12,858, class B £16,307, class C £21,560. The long tail class C ties up the most money in both cases. Tap or click to open full screen and move around

Seasonal stock you order once: the newsvendor problem

Some products are ordered once per season: Christmas decorations, a garden range, a limited edition. There is no second order. Order too few and you lose sales at full margin, too many and the rest goes into a clearance at a loss. This is the newsvendor problem, named after a vendor who must decide each morning how many papers to buy20.

The answer weighs the two mistakes. The underage cost CuC_u is what one unit too few costs you, the lost contribution. The overage cost CoC_o is what one unit too many costs you, its cost minus whatever you recover. The best order quantity is the one at which the probability of selling out equals the critical ratio20 (see Foundations: expected value):

F(Q∗)=CuCu+CoQ∗=μ+z σF(Q^*) = \frac{C_u}{C_u + C_o} \qquad Q^* = \mu + z\, \sigma

where Q∗Q^* is the best order quantity, F(Q∗)F(Q^*) is the probability that demand is at most Q∗Q^*, μ\mu and σ\sigma are the mean and standard deviation of the season's demand forecast, and zz is the point of the standard normal distribution with that probability below it. When a missed sale costs more than a leftover unit, the ratio is above 0.5 and you order more than the average forecast. When a leftover costs more, you order less.

Example: how many Fenwick star lamps to order

The Fenwick star lamp sells for £45 including VAT, which is £37.50 without VAT. It costs £16 from the supplier. Each order costs £6.50 to pick, pack and ship, and the payment fee is 1.7%, so £0.77. Leftover lamps go into the January sale at £20 including VAT, £16.67 without VAT, which after fulfilment and the fee brings 16.67−6.50−0.34=9.8316.67 - 6.50 - 0.34 = 9.83. Storing a leftover lamp until January costs about £1.

  • Underage cost, the contribution lost per missed sale: 37.50−16−6.50−0.77=37.50 - 16 - 6.50 - 0.77 = £14.23.
  • Overage cost, the loss per leftover lamp: 16−9.83+1=16 - 9.83 + 1 = £7.17.
  • Critical ratio: 14.23÷(14.23+7.17)=0.66514.23 \div (14.23 + 7.17) = 0.665.
  • The forecast for the season is 600 lamps with a standard deviation of 150. The normal point with 66.5% below it is z=0.43z = 0.43.
  • Order: 600+0.43×150=664600 + 0.43 \times 150 = 664 lamps.

Now suppose there is no clearance channel, because the lamp carries the 2026 date and will not sell in January. The overage cost becomes the full £16 plus £1 storage, £17. The ratio drops to 14.23÷(14.23+17)=0.45614.23 \div (14.23 + 17) = 0.456, z=−0.11z = -0.11, and the order becomes 600−0.11×150=583600 - 0.11 \times 150 = 583 lamps, below the average forecast. Same forecast, different economics, 81 lamps apart. And both answers need the standard deviation: a forecast without a range cannot answer this question at all.

Revenue from cohorts and orders: forecast the parts separately

Revenue is two flows: orders from new customers, which depend mostly on marketing spend, and orders from existing customers, which follow from the cohorts you already have. The first is a decision, the second close to arithmetic, so forecast them separately.

The returning part comes straight from cohort analysis: each cohort of past customers places orders at a rate that depends on its age. Group cohorts by age, multiply each group's size by its order rate, and add up. See Foundations: expected value:

R=(nnew+∑gNg rg)×AOVR = \Big(n_{\text{new}} + \sum_{g} N_g\, r_g\Big) \times \text{AOV}

where RR is the revenue forecast for the month, nnewn_{\text{new}} is the forecast number of first orders, NgN_g is the number of customers in cohort age group gg, rgr_g is the average number of orders per customer per month for that age group, and AOV is the average order value. The new customer part comes from the planned ad spend divided by the cost of winning a customer, the subject of customer acquisition cost and payback.

The two parts also differ in uncertainty. If the errors of the two parts are independent, their standard deviations combine like this (see Foundations: spread):

σtotal=σnew2+σret2\sigma_{\text{total}} = \sqrt{\sigma_{\text{new}}^2 + \sigma_{\text{ret}}^2}

where σtotal\sigma_{\text{total}} is the standard deviation of the total order forecast, σnew\sigma_{\text{new}} that of the new customer orders and σret\sigma_{\text{ret}} that of the returning orders.

Example: January 2027 revenue at Wrenfield Home

January is quieter, and Priya plans less ad spend. The forecast for first orders is 1,150. The returning orders come from the cohorts (invented example rates):

Cohort age groupCustomersOrders per customer per monthOrders
1 to 3 months (October to December 2026)5,6000.040224
4 to 12 months (January to September 2026)11,2500.024270
13 months and older38,0000.005190
Returning, total684

Total orders: 1,150+684=1,8341{,}150 + 684 = 1{,}834. Revenue: 1,834×72=1{,}834 \times 72 = £132,048 including VAT.

Callum puts an 80% range on each part from past forecast errors: plus or minus 15% on new customers (ad auctions move), plus or minus 6% on returning orders (cohorts are steady). As standard deviations, that is 0.15×1,150÷1.28=134.60.15 \times 1{,}150 \div 1.28 = 134.6 orders and 0.06×684÷1.28=32.00.06 \times 684 \div 1.28 = 32.0 orders. Combined: 134.62+32.02=138.4\sqrt{134.6^2 + 32.0^2} = 138.4 orders, so an 80% range of 1.28×138.4=1771.28 \times 138.4 = 177 orders, or 177×72=177 \times 72 = £12,744. January revenue: about £132,000, likely between about £119,300 and £144,800. Almost all of the uncertainty sits in the new customer part, which is the part Priya controls through the budget.

Cash: when the money actually moves

Profit and cash are different things, and a growing shop can run out of cash while profitable. A cash forecast moves each forecast item to the date it hits the bank: customer payments within days, stock on the supplier's terms, VAT in one lump after the quarter.

In the UK, a VAT return usually covers three months, and the return and the payment are due one calendar month and seven days after the end of the period21. So the VAT on the Christmas quarter, October to December, is due on 7 February, in what is often the quietest month of the year. This is general information on timing, not tax advice: your accountant confirms your own periods and dates.

Example: the cash forecast for February 2027

Callum builds February 2027 from the forecasts (invented example; payments assumed to settle within the month):

  • Opening balance on 1 February: £85,000.
  • Customer receipts: 1,760 forecast orders at £72 is £126,720. Minus payment fees of 1.7%, £2,154, and refunds of 9%, £11,405, leaves £113,161.
  • Stock: January's purchases for spring, on 30 day terms: £52,000.
  • Ads: £12,000. Fulfilment: 1,760×6.50=1{,}760 \times 6.50 = £11,440. Fixed costs: £19,500.
  • VAT for October to December 2026, due 7 February. Sales in the quarter including VAT: (1,980+3,500+2,600)×72=(1{,}980 + 3{,}500 + 2{,}600) \times 72 = £581,760. Without VAT: 581,760÷1.2=581{,}760 \div 1.2 = £484,800. After 9% refunds: £441,168, so output VAT of 441,168×0.2=441{,}168 \times 0.2 = £88,234. Stock bought at 48% of that, £211,761, carries input VAT of £42,352. VAT payable: 88,234−42,352=88{,}234 - 42{,}352 = £45,882. (The example counts input VAT on stock only, so the real bill would be a little lower.)

Closing balance: 85,000+113,161−52,000−12,000−11,440−19,500−45,882=85{,}000 + 113{,}161 - 52{,}000 - 12{,}000 - 11{,}440 - 19{,}500 - 45{,}882 = £57,340.

Waterfall chart of Wrenfield Home's forecast cash movements in February 2027, invented example. Opening balance £85,000. Customer receipts after fees and refunds add £113,161. Stock payments take £52,000, ads £12,000, fulfilment £11,440, fixed costs £19,500 and the VAT for October to December £45,882. The closing balance is £57,340. Tap or click to open full screen and move around

The month ends positive, at £57,340, but the VAT payment alone takes more than half of the opening balance. Run the same forecast with the bottom of the 80% revenue range, about 10% fewer orders, and receipts fall by about £10,900, so February ends at about £46,400. Bring March's £52,000 stock payment forward into February as well, as the supplier asked for this year, and the account ends about £5,600 overdrawn. Known in September, it can still be changed: Priya moves part of the spring order to 60 day terms. That is what a cash forecast is for.

Choosing the method for each series

With the pieces in place, the choice per series follows four questions, in this order.

Tap or click to open full screen and move around

Example: the backtest in Python for every product at once

The statistical models run on all products in one call with the statsforecast library, on the weekly demand series from the SQL above, in the long format of unique_id, ds and y22. MSTL handles the 52 week season, and Croston covers the long tail:

import pandas as pd
from statsforecast import StatsForecast
from statsforecast.models import CrostonOptimized, MSTL, SeasonalNaive

df = pd.read_csv("weekly_demand.csv", parse_dates=["ds"])  # unique_id, ds, y

sf = StatsForecast(
    models=[SeasonalNaive(season_length=52), MSTL(season_length=52), CrostonOptimized()],
    freq="W-MON",
    n_jobs=-1,
)
cv = sf.cross_validation(df=df, h=12, step_size=4, n_windows=6)

def wape(group, model):
    return (group["y"] - group[model]).abs().sum() / group["y"].sum()

scores = {m: wape(cv, m) for m in ["SeasonalNaive", "MSTL", "CrostonOptimized"]}

cross_validation moves the cutoff forward six times, four weeks apart, and forecasts 12 weeks from each23. The result has one row per product, test week and cutoff, with the actual value and each model's forecast side by side, so WAPE by class or category is one groupby away. The forecasts go back into a table in the shop's own database, so the admin shows each product's reorder point next to its stock.

What owning the system adds to forecasting

Nothing in this chapter needs a particular platform: a rented platform with a good export can feed the same Python. Owning the system changes the plumbing. The stock movements, the promotions calendar, the newsletter schedule and the supplier lead times all live in the same database as the orders, so the features a forecast needs are one query away, not four exports from four apps. The forecast can be written back where the decisions happen: a reorder suggestion on the product page in the admin, a purchase order drafted by a background job, a cash view next to the order report. Chapter 3, automating shop operations, shows that side, and the shop database as the source of truth the data side.

This is also work I do for clients: forecasting, lifetime value and segmentation as part of Data Science, on shops I build on Ruby on Rails and Solidus, with the code belonging to the client once paid.

Example: the forecasting rhythm at Wrenfield Home

  • Every Monday: the background job refits the models, writes forecasts and reorder points, and flags every A product below its reorder point.
  • Every month: Callum scores last month's forecasts by level and checks the interval coverage.
  • Every quarter: the cash forecast for the next six months, with a low revenue scenario, and the service levels per class.
  • Once a year, in summer: the newsvendor orders for Christmas, from the forecast range and the margins, not last year's number plus a feeling.

Conclusion

A shop forecast exists to make a decision: what to reorder and when, how much seasonal stock to buy, and whether the cash will hold. Choose the level the decision is made at, and accept that a single slow product cannot be forecast week by week. Forecast demand, not sales, by correcting for the days a product was sold out. Start from the seasonal naive baseline aligned on events, use smoothing with a seasonal decomposition for totals and categories, regression or gradient boosting where promotions and holidays drive sales, and Croston's method for the long tail. Reconcile the levels so they add up. Score on weeks the model never saw with WAPE and MASE, not MAPE, and check that an 80% interval really contains 80% of outcomes. Then turn the forecast into decisions: a reorder point from the forecast error and a service level per class, a newsvendor order from the margins, revenue from new customers plus cohorts, and a cash forecast that shows the VAT month early enough to act. How far can you trust it? Exactly as far as the backtest says, and no further.

If you want forecasts you can order stock and plan cash by, built from your own shop data, book the free workshop: we map your three most important forecast decisions together, and the first two weeks of work are on me.

Sources

  1. 1.

    Rob J Hyndman and George Athanasopoulos, Forecasting: Principles and Practice, third edition, OTexts, Melbourne, 2021, https://otexts.com/fpp3/

  2. 2.

    Solidus, core database schema migration solidus_one_four (tables spree_stock_movements, spree_stock_items, spree_variants, spree_line_items, spree_orders), GitHub, checked 22 November 2026, https://github.com/solidusio/solidus/blob/main/core/db/migrate/20160101010000_solidus_one_four.rb

  3. 3.

    Solidus, Spree::StockItem model (adjust_count_on_hand and set_count_on_hand), GitHub, checked 22 November 2026, https://github.com/solidusio/solidus/blob/main/core/app/models/spree/stock_item.rb

  4. 4.

    The PostgreSQL Global Development Group, Date/time functions and operators (date_trunc, AT TIME ZONE), PostgreSQL documentation, https://www.postgresql.org/docs/current/functions-datetime.html

  5. 5.

    Rob J Hyndman and George Athanasopoulos, Forecasting: Principles and Practice, third edition, section 5.2, Some simple forecasting methods, OTexts, 2021, https://otexts.com/fpp3/simple-methods.html

  6. 6.

    Spyros Makridakis, Evangelos Spiliotis and Vassilios Assimakopoulos, M5 accuracy competition: Results, findings, and conclusions, International Journal of Forecasting, volume 38, number 4, pages 1346 to 1364, 2022, https://econpapers.repec.org/RePEc:eee:intfor:v:38:y:2022:i:4:p:1346-1364

  7. 7.

    Rob J Hyndman and George Athanasopoulos, Forecasting: Principles and Practice, third edition, chapter 8, Exponential smoothing, OTexts, 2021, https://otexts.com/fpp3/expsmooth.html

  8. 8.

    Rob J Hyndman and George Athanasopoulos, Forecasting: Principles and Practice, third edition, section 13.1, Weekly, daily and sub daily data, OTexts, 2021, https://otexts.com/fpp3/weekly.html

  9. 9.

    Nixtla, statsforecast source code, ets.py (no seasonal component for a season longer than 24 periods), GitHub, checked 22 November 2026, https://github.com/Nixtla/statsforecast/blob/main/python/statsforecast/ets.py

  10. 10.

    Rob J Hyndman and George Athanasopoulos, Forecasting: Principles and Practice, third edition, section 7.4, Some useful predictors, OTexts, 2021, https://otexts.com/fpp3/useful-predictors.html

  11. 11.

    Rob J Hyndman and George Athanasopoulos, Forecasting: Principles and Practice, third edition, section 13.2, Time series of counts, OTexts, 2021, https://otexts.com/fpp3/counts.html

  12. 12.

    Nixtla, mlforecast documentation, Exogenous features, checked 22 November 2026, https://nixtlaverse.nixtla.io/mlforecast/docs/how-to-guides/exogenous_features.html

  13. 13.

    Rob J Hyndman and George Athanasopoulos, Forecasting: Principles and Practice, third edition, section 11.3, Forecast reconciliation, OTexts, 2021, https://otexts.com/fpp3/reconciliation.html

  14. 14.

    Rob J Hyndman and George Athanasopoulos, Forecasting: Principles and Practice, third edition, section 11.2, Single level approaches, OTexts, 2021, https://otexts.com/fpp3/single-level.html

  15. 15.

    Rob J Hyndman and Anne B Koehler, Another look at measures of forecast accuracy, International Journal of Forecasting, volume 22, number 4, pages 679 to 688, 2006, preprint at https://robjhyndman.com/papers/mase.pdf

  16. 16.

    Rob J Hyndman and George Athanasopoulos, Forecasting: Principles and Practice, third edition, section 5.8, Evaluating point forecast accuracy, OTexts, 2021, https://otexts.com/fpp3/accuracy.html

  17. 17.

    Rob J Hyndman and George Athanasopoulos, Forecasting: Principles and Practice, third edition, section 5.10, Time series cross validation, OTexts, 2021, https://otexts.com/fpp3/tscv.html

  18. 18.

    MIT Center for Transportation and Logistics, Key concepts, week 7 lesson 1: Probabilistic inventory models, CTL.SC1x Supply Chain and Logistics Fundamentals, MITx on edX, 2015, https://courses.edx.org/asset-v1:MITx+CTL.SC1x_1+2T2015+type@asset+block/KeyConcept_Week7Lesson1.pdf

  19. 19.

    Dennis Bricker, Reorder point (lecture slides, with the distribution of lead time demand and a normal distribution table), Department of Mechanical and Industrial Engineering, University of Iowa, https://user.engineering.uiowa.edu/~dbricker/Lecture_Slides/Reorder_Point.pdf

  20. 20.

    MIT OpenCourseWare, Newsvendor inventory problem, course 15.772J D Lab: Supply Chains, Fall 2014, https://ocw.mit.edu/courses/15-772j-d-lab-supply-chains-fall-2014/6952be57b43aa185119c6f114908bcc5_MIT15_772JF14_Newsboy.pdf

  21. 21.

    GOV.UK, VAT Returns, HM Revenue and Customs, checked 22 November 2026, https://www.gov.uk/vat-returns

  22. 22.

    Nixtla, statsforecast documentation, Quick start, checked 22 November 2026, https://nixtlaverse.nixtla.io/statsforecast/docs/getting-started/getting_started_short.html

  23. 23.

    Nixtla, statsforecast documentation, Cross validation, checked 22 November 2026, https://nixtlaverse.nixtla.io/statsforecast/docs/tutorials/crossvalidation.html