Discrete Demand, Extensions, and Simulation

Manuel D. Rossetti, PhD P.E.

Agenda

  • Demand counted in small whole numbers, and the staircase rule
  • A one-time buy of spare transformers, walked one unit at a time
  • When rounding the normal answer fails
  • Four extensions: a penalty, stock on hand, a model that refuses, and the single-period test
  • The final buy estimated by simulation, and when simulation is worth it

When Demand Is Counted in Small Whole Numbers

A discrete distribution function is a staircase, so the inverse \(F^{-1}\) does not exist and a critical ratio almost never lands on a step. The marginal argument of the first session still runs, one unit at a time:

\[ \begin{aligned} c_u\,P\{X > Q\} &> c_o\,P\{X \le Q\} &&\text{the next unit is worth buying}\\ c_u\big(1 - F(Q)\big) &> c_o\,F(Q) &&P\{X > Q\} = 1 - F(Q)\\ F(Q) &< \frac{c_u}{c_u + c_o} &&\text{collect } F(Q)\\ Q^{*} &= \min\left\{Q : F(Q) \ge \frac{c_u}{c_u + c_o}\right\} &&\text{stop at the first failure} \end{aligned} \]

It is not an inverse. It is the smallest quantity whose cumulative probability reaches the ratio, and there \(F(Q^{*})\) is usually strictly greater. That gap is the staircase: a discrete newsvendor achieves a little better service than its costs call for, because it cannot buy a fraction of a unit.

A One-Time Buy of Spare Transformers

The utility storeroom’s pad-mount transformer, $3,800. A capital project will change the specification, so transformers not used become obsolete. Failures over the project window: Poisson with \(\lambda = 6\).

\[ \begin{aligned} c_o &= 3800 - 900 = \$2{,}900 &&\text{bought and unused, scrapped at \$900}\\ c_u &= 9500 - 3800 = \$5{,}700 &&\text{a failure covered by an emergency purchase}\\ \frac{c_u}{c_u + c_o} &= \frac{5700}{8600} = 0.662791 &&\text{critical ratio} \end{aligned} \]

\(Q\) \(F(Q)\) Expected shortage \(G^{1}(Q)\) Expected cost Against 0.6628
4 0.2851 2.2330 $13,404 short, add one
5 0.4457 1.5181 $10,155 short, add one
6 0.6063 0.9637 $8,288 short, add one
7 0.7440 0.5700 $7,802 clears it: stop
8 0.8472 0.3140 $8,501 the check: cost rises

Does Rounding the Normal Answer Work?

Treat demand as normal with mean 6 and variance 6: \(6 + \Phi^{-1}(0.6628)\sqrt{6} = 6 + 0.4201(2.4495) = 7.029\), which rounds to 7. It agrees.

Now change one number: the emergency purchase costs $8,150, so \(c_u = \$4{,}350\) and the ratio is exactly 0.6000. What do the exact rule and the normal say?

Reads Answer
Exact rule \(F(5) = 0.4457\), \(F(6) = 0.6063\) 6
Normal approximation \(6 + 0.2533(2.4495) = 6.621\) 7

The approximation buys one transformer too many, $3,800, a real error on a real decision.

When the approximation is safe

When one unit is a small fraction of the standard deviation. At \(\lambda = 6\) one transformer is \(1/2.45 = 40\%\) of it, and rounding decides the answer; at \(\lambda = 600\) it is 4%. Use the staircase rule whenever the numbers are small, which is when items are slow-moving and each unit is expensive.

A Penalty Beyond the Lost Margin

Four extensions cover most of what a real single-period problem adds. None changes the critical ratio’s form; they change what goes into it.

\(c_u = s - c\) is the whole underage cost only if a customer turned away returns next time as though nothing happened. Let \(\pi\) represent the stockout penalty per unit of unmet demand, so \(c_u = s - c + \pi\).

For the belt, suppose a refused dealer costs $40 in future business:

\[ \begin{aligned} c_u &= 45 + 40 = 85, \qquad \frac{85}{85 + 38} = 0.6911 &&\text{from } 0.5422\\ Q^{*} &= 465.37 + 0.4988(92.64) = 511.58 \to \textbf{512 belts} &&\text{from 475} \end{aligned} \]

A penalty under half the selling price moved the order by 37 belts, 7.8%.

\(\pi\) is the parameter no ledger contains. Report the decision as: 475 belts if a stockout costs only the margin, 512 if it costs $40 more, and the organization should say which it believes.

Stock Already on Hand

With \(I\) belts already held, the model determines the quantity that should be available: the order-up-to level \(S^{*}\). The cost of ending with \(S - X\) units does not care how they got there:

\[ S^{*} = F^{-1}\!\left(\frac{c_u}{c_u + c_o}\right), \qquad Q^{*} = \left(S^{*} - I\right)^{+} \]

Already on hand \(S^{*}\) Order
0 475.18 475
120 475.18 \(475.18 - 120 = 355.18 \to\) 355
600 475.18 0: over-stocked before it begins

The truncation at zero matters: a newsvendor cannot sell stock back.

This is the first appearance of a structure the rest of the book uses constantly: chapter 8’s order-up-to policies are this idea with a trigger attached.

When the Model Refuses, and Is It Really One Period?

If \(c_u \le 0\) the ratio is zero or negative: order nothing. Correct, and usually a mis-stated problem: an item nobody loses by running out of is one nobody should stock.

If \(c_o \le 0\), salvage at least the purchase cost, the ratio is one or more: order without limit. Also correct, and also a sign of a mis-statement: a unit that can always be disposed of for what it cost carries no risk. Find the cost you left out.

The strongest assumption is in the title: leftover stock has no value after the period. Exactly true for a newspaper, a flu vaccine, the belt’s final buy. False for most inventory, where a leftover is available next week.

The test

What is a leftover unit worth at the end of the period? Its scrap value: a newsvendor problem. Nearly what you paid: not one, and chapter 8 is where to go.

Estimating the Answer by Simulation

The first simulation in the book. The closed form already gives the belt’s exact answer, so simulating it proves nothing about the belt. It proves the simulation is right, which is worth having before pointing it where no formula exists.

val demand = NegativeBinomialRV(probOfSuccess = 0.054222, numSuccess = 26.6798, streamNum = 1)
val stat = Statistic("profit at Q")
demand.resetStartStream()
repeat(100_000) {
    val d = demand.value
    stat.collect(s * minOf(d, q) + u * maxOf(0.0, q - d) - c * q)
}
println("%.2f +/- %.2f".format(stat.average, stat.halfWidth))

The model is the profit expression on sampled demand, from the fitted negative binomial, not the normal approximation: the simulation samples counts as easily as real numbers. resetStartStream before each candidate makes every quantity face the same hundred thousand demands, so rows compare with each other, and each row is reproducible on its own.

Five Agreements, Not One

\(Q\) 440 460 469 490 510
Estimated profit $17,737.18 $17,877.57 $17,893.03 $17,818.04 $17,610.98
Half-width $21.02 $24.68 $26.31 $29.95 $33.15
Closed form $17,732.96 $17,871.00 $17,886.06 $17,811.30 $17,606.01

At \(Q^{*} = 469\) the interval is \([\$17{,}866.72, \$17{,}919.34]\), and the exact $17,886.06 lies inside it, as it does in every column. Five agreements are more convincing than one, and cost nothing extra. The simulation peaks at the same candidate, which the common demands make a fair comparison.

What it has that the formula does not: every figure carries a half-width. A simulated answer without its interval is a number that is not there.

What it costs: the half-width shrinks with the square root of the replications, so ten times the precision costs a hundred times the run. Simulation is not how you solve the newsvendor.

When Simulation Is Worth It

Simulation earns its place the moment an assumption behind the critical ratio fails. Four failures are common:

  • No convenient inverse. A mixture has no closed-form quantile; the formula needs a search, the simulation does not care.
  • A salvage rule that is not linear. The scrap dealer takes the first 100 belts at $12 and the rest at $4: \(c_o\) is no longer constant, the derivation breaks, and three lines of the simulation change.
  • A constraint. A budget is the easy case, by a multiplier. A supplier minimum or a case quantity makes the order jump, and a search over simulated costs is often the shortest route.
  • Items that interact. Two products sharing one display, or refused demand substituted to another. No formula; an obvious simulation.

In all four the policy stays simple, one quantity chosen once, and what changes is the cost function. A cost function is easier to sample than to integrate.

What We Did Today

The staircase rule: the smallest \(Q\) whose cumulative probability reaches the ratio. For the transformers, 7, confirmed by the cost column.

Rounding the normal answer fails when one unit is a large fraction of \(\sigma\): at a ratio of 0.6, it buys one $3,800 transformer too many.

Extensions change what goes into the ratio: a $40 penalty moves the belt to 512; stock on hand gives an order-up-to level.

The single-period test: what is a leftover worth at the end of the period?

Simulation agreed with the closed form at all five quantities, and is worth its cost only where the formula breaks.

For Next Time

Read before next session: Building These Models in a Worksheet and Designing the Software.

Today’s material was Discrete Demand, Extensions and Estimating the Answer by Simulation.

Next session:

  • The five sheets of the workbook, and the cells that carry the mathematics
  • Reading the sheets on the final buy, and a scrap offer priced on them
  • The software, its two routes that must agree, and a salvage rule no formula takes

Bring the two-tier scrap dealer. The code prices it.

⌂ Index