Empirical Demand Distribution — from your order history to a buffer¶
Where you see it: the IO tab of a series → panel Safety Stock ↔ Fill Rate — Evidence → block C · Fill rate ↔ Safety stock (a 40-bar density of the list, the fill-rate curve, the committed reorder point, and
μ · σ · nabove the chart). It is switched on and tuned in the MEIO scenario editor → Advanced → Empirical distributions and Demand window.
In one paragraph¶
To size a buffer, the optimizer must know how much demand can arrive while it waits for a replenishment. Instead of assuming a bell curve, it uses what actually happened: for every past order it records how much was demanded during that order's own lead time. That list of numbers is the empirical distribution. The fill rate of a buffer is the share of the list at or below it, and the optimizer adds stock until that share reaches the target. Nothing is fitted, so intermittent, lumpy or skewed demand keeps its real shape. The list is a record of the past, not a forecast: it assumes the past repeats.
What the optimizer does depends on how much history a SKU has:
| History | What the optimizer reads | Typical SKU |
|---|---|---|
| 10 or more windows | the list, as it is | A and B items with a steady order history |
| 3 to 9 windows | the weekly × lead-time convolution: it shuffles the weeks of demand it has seen, as many as the lead time covers | new or slow items |
| Fewer than 3 windows, or no order rows of its own | a classical formula: Poisson (or Normal above 25 demand streams) | brand-new items; warehouses that only supply other locations |
Three words used on this page
- Window — one past order and the demand that accrued during its own lead time (Step 1 below). The number of windows is the size of a SKU's list.
- Regime — which of the three cases above applies. It depends only on the number of windows: fewer than
3, 3 to 9, or 10 or more (
empirical_min_windows). - Bucket — a lead-time class that the windows of one list are sorted into: 0–7, 8–14, 15–30, 31–60 or 61+ days (by the actual lead time of each window). Buckets have nothing to do with regimes: they only decide whether the optimizer reads one bucket of a list or the whole list (see What a real tenant looks like).
flowchart LR
accTitle: From order history to a reorder point
accDescr: Each demand row with a received date becomes one window. With ten or more windows the sorted list is used. With three to nine, the weekly demand is combined with the observed lead times by simulation. With fewer, a classical formula is used. Either way a fill rate is read from the result and the optimizer picks the first whole-unit buffer that reaches the target.
A["INPUT — demand rows with a received date<br/>(last 52 weeks by default)"]
B["PROCESS — one window per row<br/>demand between its date and its received date"]
C{"how many<br/>windows?"}
D["OUTPUT — the list<br/>sorted demand-over-lead-time values"]
E["PROCESS — weekly x lead-time<br/>convolution (simulation)"]
F["PROCESS — classical formula<br/>Poisson, or Normal above 25 streams"]
G["PROCESS — fill rate of a buffer<br/>= share of the values at or below it"]
H["OUTPUT — reorder point<br/>first whole-unit buffer that reaches the target"]
A --> B --> C
C -- "10 or more" --> D --> G
C -- "3 to 9" --> E --> G
C -- "fewer than 3" --> F --> H
G --> H
classDef io fill:#e7f6f0,stroke:#10b981,color:#1b4332;
classDef proc fill:#eef2ff,stroke:#6366f1,color:#312e81;
class A,D,H io;
class B,C,E,F,G proc;
One example, start to finish¶
An intermittent SKU: 12 weeks of history, replenishment lead time 2 weeks, 95 % fill-rate target. Every demand row was received 14 days after its date. Weekly demand, W1 to W12:
0 5 0 0 20 0 0 0 15 0 0 10 (mean 4.17 a week)
Step 1 — Build the list: one window per past order¶
Each row opens a window from its date to its received date and adds up the demand that falls inside it. With a 2-week lead time a window is that week plus the next; the last one holds only W12 because the history ends.
| Order placed in | Its own demand | + next week | Window = demand during its lead time |
|---|---|---|---|
| W1 | 0 | 5 | 5 |
| W2 | 5 | 0 | 5 |
| W3 | 0 | 0 | 0 |
| W4 | 0 | 20 | 20 |
| W5 | 20 | 0 | 20 |
| W6 | 0 | 0 | 0 |
| W7 | 0 | 0 | 0 |
| W8 | 0 | 15 | 15 |
| W9 | 15 | 0 | 15 |
| W10 | 0 | 0 | 0 |
| W11 | 0 | 10 | 10 |
| W12 | 10 | (history ends) | 10 |
Sorted, this is the list: 0 0 0 0 5 5 10 10 15 15 20 20 — 12 values, mean 8.33. In words: during one lead
time, this SKU has seen nothing a third of the time, and as much as 20 units.
Step 2 — Read a fill rate off the list¶
The fill rate of a buffer is the share of the list at or below it, with a straight line between neighbouring values so that every extra unit counts. It is 0 below the smallest value and 100 % at the largest.
| Buffer (units) | 0 | 5 | 10 | 15 | 18 | 19 | 20 |
|---|---|---|---|---|---|---|---|
| Fill rate | 29 % | 46 % | 63 % | 79 % | 84 % | 86 % | 100 % |

Step 3 — The optimizer picks the reorder point¶
It stops at the first whole-unit buffer whose fill rate reaches 95 %: 20 units (19 gives only 86 %). Safety stock is that minus the mean demand over the lead time: 20 − 8.33 = 11.7 units.
For comparison, the textbook formula on the same 12 weeks assumes demand is normal: σ = 7.02 a week, safety stock = 1.645 × 7.02 × √2 = 16.3, reorder point 24.7. The list is lower because it follows the real shape — a spike at zero and a fat right tail — instead of a symmetric bell.
The list cannot see past its largest value
20 is also the largest value the list has ever seen: the fill rate jumps from 86 % to 100 % at that point. With only 12 windows that is a floor, not a promise. The next section shows what happens when the history is shorter, and the accuracy tables further down show how fast this improves with history.
The same SKU as its history grows¶
Take the same SKU at an earlier moment, with only its first n weeks of history, and let the optimizer size it:
| Weeks of history | Windows | What the optimizer reads | Reorder point | Fill rate it believes |
|---|---|---|---|---|
| 2 | 0 | classical Poisson | 9 | 97 % |
| 5 | 5 | weekly × lead-time convolution | 25 | 96 % |
| 8 | 8 | weekly × lead-time convolution | 20 | 96 % |
| 10 | 10 | the list | 20 | 100 % |
| 12 | 12 | the list | 20 | 100 % |
The three ways in detail:
Too few data points (fewer than 3 windows) — a classical formula. Two weeks of history give no window at
all (the builder needs 3), so no list exists — silently: the run log only counts how many SKUs received one. The
optimizer assumes a distribution: Poisson by default, which reads only the mean demand over the lead time
(here 2 weeks × 2.5 = 5, reorder point 9). Normal is used instead for an item with more than 25 demand
streams (sku_count, the kinds of rolled-up demand stored for it, at most 5 — so in practice never). Poisson
assumes the variance equals the mean, whatever the observed variability.
Few data points (3 to 9 windows) — the convolution. A list of 8 windows cannot see beyond its own largest
value, so the optimizer does not read it. It uses the weeks instead: each simulation trial draws a lead time
from the lead times actually observed (here always 14 days = 2 weeks), then adds that many weekly demand values
drawn at random from the history. Our 8 weeks are 0 5 0 0 20 0 0 0; one trial might draw 5 and 20 (= 25),
another 0 and 0 (= 0). After 5,000 trials the sorted totals form the list, and Step 2 and Step 3 apply to it
as before. Eight weeks produce 8 × 8 = 64 combinations instead of 8 windows, and a lead time that is not a whole
number of weeks is pro-rated (10 days = one weekly draw plus 3/7 of another). The draws are seeded per SKU, so a
rerun gives the same result. This replaces the previous behaviour, where an 8-window list was read as it was.
Plenty of data points (10 windows or more) — the list. From 10 windows on the list is read as in Steps 1–3.
Windows are not independent (every week above sits in two of them), so 10 windows carry about five independent
2-week blocks of information; that is why the boundary is not lower. A scenario can move it
(empirical_min_windows, below).
How well does each way work? (a case where the truth is known)¶
The examples above have no "right answer". To measure accuracy, take a synthetic SKU whose weekly demand follows a known distribution (mean 10 a week, variance 20) with a 14-day lead time. True demand over the lead time is then known: mean 20, 95 % point 31, 99 % point 37. The tables show the fill rate the optimizer believes next to the real chance of no stock-out at the reorder point it chose. Every figure is produced by the real optimizer extension (2 Dec 2026); the last section says how to reproduce them.
With a full year (52 weekly rows) the list works well:
| Target | Reorder point | Fill rate the list promises | Real chance of no stock-out |
|---|---|---|---|
| 90 % | 30 | 90.4 % | 94.1 % |
| 95 % | 33 | 95.2 % | 97.3 % |
| 99 % | 42 | 100 % | 99.8 % |
With little history it does not. 400 simulated histories per length, 95 % target — average real chance of no stock-out, and the share of histories that ended below 90 %:
| Weekly rows | Own list | …under 90 % | Resampled list | Convolution | …under 90 % | Poisson | Normal | What a run reads |
|---|---|---|---|---|---|---|---|---|
| 4 | 70.9 % | 75 % | 70.9 % | 84.8 % | 40 % | 83.9 % | 86.5 % | 84.8 % |
| 6 | 80.8 % | 59 % | 80.8 % | 86.9 % | 41 % | 86.5 % | 90.2 % | 86.9 % |
| 8 | 85.0 % | 52 % | 85.0 % | 88.8 % | 37 % | 85.8 % | 90.7 % | 88.8 % |
| 10 | 88.4 % | 42 % | 88.4 % | 90.9 % | 30 % | 87.3 % | 92.2 % | 88.4 % |
| 12 | 90.3 % | 31 % | 90.3 % | 91.9 % | 25 % | 87.5 % | 92.6 % | 90.3 % |
| 20 | 92.8 % | 22 % | 92.1 % | 93.4 % | 20 % | 88.3 % | 93.6 % | 92.8 % |
| 52 | 94.8 % | 8 % | 94.5 % | 94.9 % | 5 % | 89.2 % | 94.7 % | 94.8 % |
| 104 | 95.3 % | 3 % | 94.8 % | 95.2 % | 1 % | 89.2 % | 95.0 % | 95.3 % |
- The list under-protects with little history and resampling it changes nothing: re-drawing from 6 windows
can never produce a value above the largest of them (5,000 draws from
3 9 9 18 18 25hold 4 distinct values and a maximum of 25). - The convolution is better below about 20 rows because it works from n weeks instead of n windows. On this
synthetic demand it is at least as good everywhere. Real demand is not independent from week to week (trends,
bursts, a long lead time catching a burst), which is exactly what a list of real windows keeps and the
convolution loses; that is why a run switches at 10 windows and not later. Raise
empirical_min_windowsto keep the convolution longer. - Poisson is steady but never reaches the target: it ignores variability (here the variance is twice the mean). It matters for SKUs with fewer than 3 windows. Normal uses the observed σ, so it tracks the target but is noisy with a short history.
- A single history is noisy. On one particular history of 6 weeks (
8 10 15 3 6 3), the list gives reorder points 25 / 25 / 25 for targets 90 / 95 / 99 % (real chance 81 %), the convolution 23 / 25 / 30 (real chance 73 % / 81 % / 94 %). Judge a method by the averages above, not by one SKU.
For a new SKU with 2 rows of this synthetic demand (rate 10 a week, lead time 2 weeks), the classical
formulas give: Poisson 28 whatever σ is (real chance 90.3 %); Normal 23, 31 or 67 for a weekly σ of 1, 4.47
or 20 — the textbook reading 1.645 · σ · √LT + mean.
What to do with a thin SKU: treat its buffer as a floor, give it a minimum (segment minimum fill rate or minimum safety stock), and let history accumulate.
What a real tenant looks like (demo tenant, pipeline 4, 15 June 2026)¶
| Windows in the list | 25 | 30–39 | 40–49 | 50–55 |
|---|---|---|---|---|
| SKUs | 1 | 4 | 559 | 23 |
587 SKUs have a list and none has fewer than 10 windows, so none uses the convolution (the median list holds 42 windows). 138 of the 725 SKUs of a fresh load have no list; in the stored results of the same run, all but one of the SKUs without a list are warehouses that only replenish others, and the last is a direct SKU with too little usable history. They run on Poisson (the items carry 1 to 3 demand streams).
Each list is also split by the actual lead time of its windows (0–7, 8–14, 15–30, 31–60, 61+ days). The optimizer reads the bucket of the route's planned lead time when that bucket has at least 30 windows (or at least a quarter of all windows); otherwise it reads the whole (pooled) list. On this tenant 579 SKUs plan for less than a week, but only 18 of the 24,809 windows are that short (79 % are 15–30 days), so 586 of the 587 read the whole list. Windows are measured from each row's own received date: check that this date means what you plan for.
Reading the Evidence panel¶
| You see | It usually means |
|---|---|
n of 30 or more in block C |
plenty of history; trust the curve |
n below about 10 and the source demand_actuals_conv |
the SKU runs on the convolution: n is the number of weeks behind it, the histogram shows the simulated totals |
| The fill-rate curve reaches 100 % exactly at the last bar | the list ran out: the buffer is the largest value ever seen |
| The message No empirical demand-over-LT distribution. Run the Distributions / MEIO V3 empirical step. | the SKU has no list and runs on the classical formula. Re-running does not help when the cause is fewer than 3 windows or a warehouse with no order rows of its own |
Settings¶
Every setting around the list — use_empirical_distributions, demand_window_weeks,
empirical_min_windows, the Few-order convolution switch (use_lead_time_distribution),
mc_iterations, mc_seed, empirical_shrinkage_n_min, and the inert bootstrap_samples —
is documented once, with its default, scope (scenario vs tenant) and exact effect, in the
MEIO parameters reference.
What changed on 2 December 2026
- SKUs with 3 to 9 windows used to read their own short list; they now use the convolution (setting
empirical_min_windows). - The convolution used to round the lead time to whole weeks with a minimum of one (a 10-day lead time drew one week of demand, a 3-day one a whole week). It now pro-rates it.
- The Normal formula now uses the textbook spread
z · σ · √LT. It used to computez · √(σ · √LT), a port of the original IO code whose own earlier version was the textbook one. It sizes SKUs above the stream threshold (none today) and every virtual zone SKU of the collaborative zone pass: a zone's pooled envelope was 166 where the textbook gives 11,748 (zone THAILANDE, 99 %). Zone buffers therefore grow on the next run of every tenant that uses zones. - These changes alter MEIO output on the next run: re-baseline golden snapshots per tenant.
Demand basis (the other way to feed the list)¶
A scenario can be sized on actuals (the default: what customers really ordered, the list described above) or on the forecast (scenario editor → Advanced → Demand basis): the SKU is then sized on the pipeline's forecast instead of its history, which also lets new items with no sales history be planned. Under the forecast basis the list is the weekly forecast path (52 weekly values), and the fill rate is read off it as if it were demand over the lead time (open point 2 below).
Known limits and open points¶
Verified on 2 December 2026 against the code and the real optimizer extension. Items marked open need a business decision; nothing was changed for them.
- The list cannot exceed its largest value, and windows overlap (Step 3).
- Forecast basis ignores the lead time (open). The weekly forecast path is used as demand over the lead time without scaling: a SKU with 10 units a week gets the same reorder point (22) for a 1-, 2- and 4-week lead time, i.e. a real chance of no stock-out of 99.0 %, 67.8 % and 1.5 %. The convolution would fix it (weekly path × lead time); not wired for the forecast basis.
- Only rows that exist open windows. For the 12 weeks
0 5 0 0 20 0 0 0 15 0 0 10: 12 windows (mean 8.33) when the zero weeks are stored as rows of 0, but only 4 windows (5 20 15 10, mean 12.5) when they have no row. The convolution treats the weeks between the first and the last row as zero demand. - The block bootstrap is not attached. The optimizer also contains a block bootstrap of observed (lead time, demand) pairs; the runner never builds the input it needs. Nothing resamples a list.
- The 10-window boundary is a judgement (open). On independent synthetic demand the convolution is better up
to about 20 windows (table above); on real demand the list keeps correlations the convolution loses. Tune
empirical_min_windowsper scenario after looking at the Evidence panel of a few thin SKUs. - The window is the order's receipt lag, not the supply lane's horizon (open). A window runs from the order's
date to its
received_date(Step 1). When that lag is a customer-fulfillment delay much longer than the replenishment lane, the thick-history list is scaled by the wrong horizon — on the demo tenant (rows carry ~19-day lags on 2-day lanes) the list's mean came out about 11× the lane's demand over lead time (found November 2026, not fixed). The 3-to-9-window convolution is not affected: it draws its lead time from the lane. Re-pointing the thick-history windows at the supply horizon needs a business decision.
For developers¶
| Item | Where |
|---|---|
| Window builder (Rust, numpy-faithful) | files/MEIO_v3/src/empirical.rs::compute_key (:199) — skip below 3 windows :247 |
| Loader, look-back, attach, persist | files/meio_runner.py::_build_and_attach_empirical_distributions (:4381) — look-back :4443, at least 3 rows :4567, few-window convolution :4591 |
| Few-window settings and helpers | _parse_empirical_min_windows (:2266), _empirical_settings (:2285), _convolution_seed (:2312), _weekly_demand_series (:2318), constants :2259-2263 |
| Per-scenario switch | _apply_few_window_convolution (:6747), called before _apply_demand_basis in the scenario chain |
| Convolution (Rust) | monte_carlo.rs::run_convolution_mc (:65, pro-rated lead time); Python entry meio_optimizer_v3.convolution_mc |
| Demand window | _parse_demand_window (:2336) |
| Lead-time buckets | LT_BUCKETS (:4786), _load_planned_lt_by_key (:4803), DistributionType::bucketed_samples (distributions.rs:97) |
| Distribution choice | DistributionType::resolve (distributions.rs:159): empirical when attached, else Normal if sku_count > distribution_threshold, else Poisson |
| Fill rate of a list | empirical_cdf (distributions.rs:370), averaged by fitted_cdf_rop_to_fr (:482) |
| Classical arms | poisson_rop_to_fr (:464), golden_formula_rop_to_fr (:395, spread :427; the long jump in marginal.rs:598) |
| Stored evidence | ClickHouse PIPE_uncertainty_distributions (dist_type='demand_over_lt'; source = demand_actuals or demand_actuals_conv; n_samples = windows, or weeks for the convolution) |
| Evidence endpoint | GET /api/meio/skus/{item_id}/{site_id}/diagnostics?pipeline_id=; panel DetailIOTab.jsx::SafetyStockEvidencePanel |
| Stale-extension guards | markers densified_empirical_supported, normal_textbook_supported (lib.rs:623), fractional_convolution_supported (lib.rs:632); _require_textbook_normal_extension (meio_runner.py:482) |
| Not wired | block bootstrap (monte_carlo.rs::resolve_compound_distributions, :129), uncertainty.rs::shrink_toward (unit test only), _any_lt_conv (meio_runner.py:640, the old convolution gate) |
| Tests | files/tests/test_meio_few_window.py (33), files/tests/test_meio_empirical_doc.py, Rust monte_carlo.rs / distributions.rs / marginal.rs tests |
| Reproduce this page | files\venv\Scripts\python.exe files/scripts/meio_empirical_demo.py (add --simulate for the 400-history table, --with-forecast-basis for open point 2, --figure PATH.png for the picture; read-only, no database) |
See also: MEIO theory (the empirical cycle-stock baseline and the greedy loop), MEIO parameters, Wait time, Safety stock fundamentals and the guide chapter Inventory optimization.