{
  "id": 21864007,
  "title": "Safety stock with uncertain lead time: the formula, a worked example, and why a sold-out week is not zero demand",
  "url": "https://urgent.news/2026/11/25/safety-stock-with-uncertain-lead-time-the-formula-a-worked-example",
  "topic": "finance",
  "section": "Finance & Markets",
  "published": "2026-11-25T21:43:37.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/tidycents/safety-stock-with-uncertain-lead-time-the-formula-a-worked-example-and-why-a-sold-out-week-is-cn"
  },
  "original_language": "en",
  "account": "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.\n\nInputs:\n- Mean demand per week: 10 units\n- Standard deviation of demand: 2 units\n- Lead time: 3 weeks\n- Standard deviation of lead time: 1 week\n- Z-score for 95% confidence: 1.6449\n\nVariance over the protection period (lead time):\n- Demand variability accumulates over lead time\n- Lead-time variability is scaled by mean demand\n- Variance formula: leadTime * sdDemand^2 + meanDemand^2 * sdLeadTime^2\n- Result: 112 units^2\n- Sigma (standard deviation): approximately 10.583 units\n\nBuffer and target stock:\n- Round up to whole units; fractional buffers cannot be rounded down\n- Buffer: ceiling of z95 * sigma = 18 units\n- Target stock: ceiling of (meanDemand * leadTime + z95 * sigma) = 48 units\n\nCurrent inventory:\n- On hand: 20 units\n- On order: 10 units\n- Backorders: 5 units\n- Current position: 25 units\n\nGap to target stock and cash in buffer:\n- Gap: max(0, target - position) = 23 units to order\n- Buffer capital cost (per unit $4): 7200 cents ($72.00)\n\nAddressing sold-out weeks:\n- A week with zero sales due to stockout is not a zero demand\n- Treating it as zero can lower mean demand and buffer, increasing the risk of future stockouts\n- Store availability should be tracked alongside sales, with stockout periods treated as missing data\n- Fit forecasts using only past history to avoid seeing future data\n\nThis 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.",
  "summary": "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…",
  "key_points": [
    "Safety stock formula combines demand and lead time uncertainties",
    "Example calculation uses JavaScript with specific inputs and Z-score",
    "Sold-out weeks are not zero demand, must be treated as missing data"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}