Definition
Demand is censored when it is observed only up to the stock available: sales equal the smaller of demand and stock. A period that ends with no stock left is a censored observation. It tells that demand was at least the quantity sold, and nothing more.
salest = min( demandt, stockt )
Treating censored sales as demand underestimates the mean and, more seriously, the upper quantiles, since the largest demands are the ones cut off. The statistical treatment is the one used for survival data: uncensored periods contribute the probability of the value seen, censored periods the probability of that value or more.
Worked example
True demand is Poisson with mean 5, and the shelf holds 6 units each period. We estimate the mean from sales, then with a likelihood that treats sold-out periods as censored.
import numpy as np
from scipy import optimize, stats
rng = np.random.default_rng(15)
demand = rng.poisson(5.0, 2_000)
stock = 6
sales = np.minimum(demand, stock)
sold_out = sales == stock
def neg_loglik(mu):
ll = stats.poisson.logpmf(sales[~sold_out], mu).sum()
ll += stats.poisson.logsf(stock - 1, mu) * sold_out.sum() # P(demand >= stock)
return -ll
fit = optimize.minimize_scalar(neg_loglik, bounds=(0.1, 30), method="bounded")
print(f"periods sold out: {sold_out.mean():.1%}")
print(f"true mean demand: 5.00")
print(f"mean of sales: {sales.mean():.2f}")
print(f"mean of sales, sold-out dropped: {sales[~sold_out].mean():.2f}")
print(f"censored-likelihood estimate: {fit.x:.2f}")Output, produced by running the code above when this page was built:
periods sold out: 38.2% true mean demand: 5.00 mean of sales: 4.48 mean of sales, sold-out dropped: 3.53 censored-likelihood estimate: 4.96
The mean of sales is below the true demand. Dropping the sold-out periods makes it worse, because it removes the periods where demand was highest. The censored likelihood recovers the mean.
Where it misleads
- The correction needs to know when the item was out of stock. Many sales histories do not record stock levels, and a zero can be no demand or no stock.
- It relies on the assumed distribution to fill in what was not observed. With heavy censoring, the estimate is mostly an assumption.
- Unmet demand does not always vanish: customers wait, substitute or go elsewhere. Sales of a neighbouring item can be inflated by the stock-out of this one.
- Public demand datasets are sales datasets. A stock simulation run on them measures service against recorded sales, which flatters every method on the items that were often unavailable.
In our work
At the start of a demand project we ask whether stock levels were recorded with sales. In our published study on four public datasets, the data are sales and we state it as a limit of the stock simulation.
Service: forecasting and statistical studies Research note: intermittent demand forecasting, measured Research note: how we treat data
References
- Nahmias, S. (1994). Demand estimation in lost sales inventory systems. Naval Research Logistics, 41(6), 739-757. doi:10.1002/1520-6750(199410)41:6<739::AID-NAV3220410605>3.0.CO;2-A
- Agrawal, N., Smith, S. A. (1996). Estimating negative binomial demand for retail inventory management with unobservable lost sales. Naval Research Logistics, 43(6), 839-861. doi:10.1002/(SICI)1520-6750(199609)43:6<839::AID-NAV4>3.0.CO;2-5
- Chadeffaud, M. (2026). Evaluating intermittent demand forecasts: a preregistered study on four public datasets. Zenodo, preprint. doi:10.5281/zenodo.24248568