Every model from here on takes a demand distribution as an input, and the distribution carries more of the answer than the policy formula built on it. The procedure is Appendix B of Simulation Modeling using the KSL, applied with one difference made explicit: demand for a spare part is a count, so every tool is discrete.
The distributor has 104 weeks of demand, recorded after the deck went out of production, in data/ch7-weekly-demand.csv:
Notice that the column types are named, not inferred. A column of counts silently read as text or as real numbers fails later, and somewhere else.
Weekly demand in bins of ten belts, each closed below and open above. The tallest bar counts the 26 weeks that sold 10 through 19.
Notice the shape: a peak well to the left, a long thin tail past 110, and no suggestion of symmetry. That single picture has already ruled out the normal.
A summary statistic answers a question you already thought to ask. A picture shows you the thing you did not.
Is it the same process throughout? No trend, no level shift, no season: the series wanders about a constant level for two years. The season really is over.
Are the weeks independent? Every lag is inside the band. The first is 0.1423 against \(\pm 1.96/\sqrt{104} = \pm 0.19\).
Thus the 104 numbers are independent, identically distributed, and strongly right-skewed: 104 draws from one distribution.
| Statistic | Value |
|---|---|
| Weeks observed | 104 |
| Mean | 33.2404 |
| Variance | 613.0387 |
| Standard deviation | 24.7596 |
| Coefficient of variation | 0.7449 |
| Skewness | 1.2630 |
| Median | 26.5 |
| Quartiles | 16.0, 40.0 |
| Range | 0 to 113 |
| Weeks with no demand | 2 |
The median sits well below the mean. 26.5 against 33.24: most weeks quiet, a few very large. The skewness and the histogram say the same thing. Three routes, one finding.
Demand is a count. Whole belts, two zeros, no meaning between integers. The candidate families are the discrete ones.
For a count, the diagnostic is the variance to mean ratio:
\[ \mathit{VMR} = \frac{613.0387}{33.2404} = 18.44 \]
the quantity each discrete family fixes or bounds.
Hypothesize. The Poisson fixes \(\mathit{VMR} = 1\); the binomial forces \(\mathit{VMR} < 1\). A ratio of 18.44 is near neither, and no parameter repairs that. What remains is the negative binomial: any \(\mathit{VMR} > 1\), a Poisson whose rate varies from week to week. A plausible story for a spare part.
Estimate. PMFModeler estimates every discrete family it knows:
RV Type = NegativeBinomial
Double Parameters {probOfSuccess=0.05422232292974839, numSuccesses=1.9057024844439698}
RV Type = Poisson
Double Parameters {mean=33.24038461538462}
FAILED: Cannot match moments when sample average <= estimated variance
RV Type = Binomial
Double Parameters {probOfSuccess=0.29133420825260514, numTrials=114.09708737864078}
The most useful line is the failure. The moment-matching binomial refuses, for the reason \(\mathit{VMR}\) gave: the software performing Step 1. The other binomial matched the largest observation and reports 114.1 trials for a quantity with no trials in it. An estimate returned is not a family appropriate.
Matching the negative binomial’s two moments to the sample mean \(\bar{x}\) and variance \(s^{2}\):
\[ \begin{aligned} \hat{p} &= \frac{\bar{x}}{s^{2}} = \frac{33.2404}{613.0387} = 0.054222 &&\text{mean over variance}\\ \hat{r} &= \frac{\bar{x}^{2}}{s^{2} - \bar{x}} = \frac{33.2404^{2}}{613.0387 - 33.2404} = 1.9057 &&\text{method of moments} \end{aligned} \]
which is what the KSL reported. Notice that \(1/\hat{p} = 18.44\) is the variance to mean ratio we started with: the fit is a restatement of two summary numbers in the parameters of a family.
The KSL uses the success convention: probOfSuccess is \(p\) and the mean is \(r(1-p)/p\). Confirm the convention every time before passing a parameter to a routine.
A chi-squared test on bins of approximately equal probability:
| Model | \(\chi^{2}\) | df | \(p\) | At 0.05 |
|---|---|---|---|---|
| Negative binomial | 23.35 | 17 | 0.1382 | do not reject |
| Poisson | 571.98 | 16 | 0.0000 | reject |
The Poisson is not rejected narrowly: its statistic is more than twenty times the negative binomial’s.
The test is the confirmation, not the decision. The ratio decided; a test that contradicted it would point at the data.
The fitted negative binomial against the 104 weeks. Read whether the curve runs through the middle of the spikes, which it does.
Failing to reject is not proof. With 104 observations over twenty bins, several bins expect fewer than five, where the chi-squared approximation is least trustworthy; the KSL flags each. The test and the ratio narrow the field, and the choice among survivors is yours to defend. Where survivors disagree enough to change the decision, compute the answer under both and report the spread.
What the section did not do:
Recall the two statistics that classify a history: the average interval between demands, \(\mathit{ADI}\), and the squared coefficient of variation of the nonzero sizes, \(\mathit{CV}^{2}\). \(\mathit{ADI} > 1.32\) is intermittent; with \(\mathit{CV}^{2} > 0.49\) too, lumpy. Syntetos and colleagues derive the cut-offs as the points where one forecasting method overtakes another.
For the belt, \(\mathit{ADI} = 104/102 = 1.02\), comfortably under: the check that licenses everything so far.
One family must explain two things. Intermittent period demand is a point mass at zero mixed with a distribution of sizes. No single family explains how often and how large at once; the repairs are a zero-modified family or a compound one.
The coefficient of variation passes where the normal is usable. At 1.0 a normal puts a sixth of its probability below zero. Intermittent items routinely run past 1.0, so the family most reached for is the one most surely wrong.
This book does not forecast intermittent series. The literature begins with Croston (1972).
Croston’s insight. Exponentially smoothing an intermittent series directly jumps at every demand and decays through every empty period. The estimate is highest immediately after a demand, when stock has just been drawn down and a replenishment is most likely to be triggered: unbiased across the series, biased upward at the only moments anyone reads it. He smoothed the size and the interval separately.
Syntetos and Boylan showed (2001) that combining the two in the obvious way is biased high, because the ratio of two smoothed estimates does not estimate the ratio of their means, and gave the correction (2005) that carries their names.
Fitting asks what the distribution of demand is. Forecasting asks what next period’s demand will be. They are different questions.
Let \(X\) represent total demand over the fourteen weeks and \(X_i\) demand in week \(i\), negative binomial with mean 33.2404 and variance 613.0387. Weeks are independent, so means and variances add:
\[ \begin{aligned} E[X] &= 14(33.2404) = 465.37, \quad \mathit{Var}[X] = 14(613.0387) = 8582.54 &&\text{independent weeks}\\ \sigma &= \sqrt{8582.54} = 92.64, \quad c_X = 92.64/465.37 = 0.1991 &&\text{spread of the total} \end{aligned} \]
Two approximations, both earned. Continuous: one belt is \(1/92.64 = 1.1\%\) of \(\sigma\), so rounding cannot decide the answer; at the weekly level it is 4%. Normal: the weekly coefficient was 0.7449, but the total’s is 0.1991, where a normal puts essentially nothing below zero, and a sum of many independent terms tends toward the normal.
\[ \begin{aligned} \frac{c_u}{c_u + c_o} &= \frac{45}{83} = 0.542169, \quad z = \Phi^{-1}(0.542169) = 0.1059 &&\text{critical ratio}\\ Q^{*} &= 465.37 + 0.1059(92.64) = 475.18 \to \textbf{475 belts} &&\mu + z\sigma\\ E[\text{shortage}] &= 92.64\,\Phi^{1}(0.1059) = 92.64(0.3482) = 32.26 &&\text{normal loss, scaled}\\ E[\text{leftover}] &= 32.26 + 475.18 - 465.37 = 42.07 &&\text{shortage} + Q - E[X]\\ E[C(Q^{*})] &= 38(42.07) + 45(32.26) = 1598.71 + 1451.72 = \$3{,}050.43 &&\text{the cost} \end{aligned} \]
The check. The other form: \((45 + 38)(32.26) + 38(475.18 - 465.37) = 2677.62 + 372.81 = \$3{,}050.43\). It catches a missing \(\sigma\) in the loss function immediately.
In business terms. Expected profit \((95 - 50)(465.37) - 3050.43 = \$17{,}891.01\): commit $23,750 for 475 belts and expect to clear about $17,900. Scrap about 42; turn away about 32 dealers.
What does ordering the mean, rounded to 465 belts, cost against the optimum’s $3,050.43?
$3,068.88, 0.6% worse. The EOQ is flat in the same way and for the same reason: a smooth objective whose derivative vanishes at the optimum.
Thus the value of this calculation is not the last belt. It is knowing that 475 is right and 700 is not: 700 costs $8,930, nearly three times the optimum.
A sum of independent negative binomials sharing \(p\) is negative binomial with the same \(p\) and the successes added. So the weekly fit gives the fourteen-week distribution exactly: \(\mathit{NB}(0.054222,\ 14 \times 1.9057 = 26.6798)\). Its smallest \(Q\) with \(F(Q) \ge 0.5422\) is 469: \(F(468) = 0.5392\), \(F(469) = 0.5434\).
| Model used to choose \(Q\) | Normal | Lognormal | Gamma | Exact NB |
|---|---|---|---|---|
| \(Q\), whole belts | 475 | 466 | 469 | 469 |
| Expected cost under the exact model | $3,061.28 | $3,057.19 | $3,055.38 | $3,055.38 |
| Penalty against the exact answer | 0.19% | 0.06% | 0.00% | 0.00% |
Read it as a bound, not a ranking. The worst family costs 0.19% more, on a decision worth about $3,050, because the total’s coefficient of variation is 0.1991. At the weekly 0.7449 it would not be small.
The normal’s defect is real and did not bite. It puts \(\Phi(-5.02)\), about one in four million, below zero here; on the weekly data, about 9%.
Look, summarize, then fit. Three plots showed the weeks independent, identically distributed and right-skewed.
The variance to mean ratio chose the family, 18.44, negative binomial; the estimator’s failure and the test confirmed it.
Intermittent demand needs other tools, and forecasting it is a different question from fitting it.
The final buy is 475 belts by the normal approximation, $17,891.01 expected profit, checked two ways.
The optimum is flat, and the family costs at most 0.19% here, because fourteen weeks aggregate away the weekly skew.
Read before next session: Discrete Demand, Extensions and Estimating the Answer by Simulation.
Today’s material was Getting a Demand Distribution, Intermittent and Slow-Moving Demand and Continuous Demand.
Next session:
The exact answer was 469, not 475. Next session’s rule is how to find it.