Safety stock with uncertain lead time: the formula, a worked example, and why a sold-out week is not zero demand
Safety stock answers one question: how many extra units do you hold so that a slow delivery or a busy week does not empty the shelf? When both demand and lead time vary, the textbook formula combines the two sources of uncertainty. Here it is in plain JavaScript with a worked example. Inputs const meanDemand = 10 ; // units per week const sdDemand = 2 ; // weekly standard deviation const leadTime…
Safety stock is the quantity of extra inventory held to avoid running out of stock due to slow deliveries or busy periods. In cases where both demand and lead time vary, the standard formula combines these uncertainties. This explanation presents the formula and an example using JavaScript.
Inputs:
- Mean demand per week: 10 units
- Standard deviation of demand: 2 units
- Lead time: 3 weeks
- Standard deviation of lead time: 1 week
- Z-score for 95% confidence: 1.6449
Variance over the protection period (lead time):
- Demand variability accumulates over lead time
- Lead-time variability is scaled by mean demand
- Variance formula: leadTime * sdDemand^2 + meanDemand^2 * sdLeadTime^2
- Result: 112 units^2
- Sigma (standard deviation): approximately 10.583 units
Buffer and target stock:
- Round up to whole units; fractional buffers cannot be rounded down
- Buffer: ceiling of z95 * sigma = 18 units
- Target stock: ceiling of (meanDemand * leadTime + z95 * sigma) = 48 units
Current inventory:
- On hand: 20 units
- On order: 10 units
- Backorders: 5 units
- Current position: 25 units
Gap to target stock and cash in buffer:
- Gap: max(0, target - position) = 23 units to order
- Buffer capital cost (per unit $4): 7200 cents ($72.00)
Addressing sold-out weeks:
- A week with zero sales due to stockout is not a zero demand
- Treating it as zero can lower mean demand and buffer, increasing the risk of future stockouts
- Store availability should be tracked alongside sales, with stockout periods treated as missing data
- Fit forecasts using only past history to avoid seeing future data
This account provides a detailed explanation of safety stock calculation, its importance, and handling of exceptional cases like sold-out weeks, without reproducing any part of the original source text.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to