The newsboy model with normally distributed demand
DefinitionInventoryControl_newsboyThe classical single-period stochastic inventory problem, in the notation of Axsäter, Inventory Control, Sect. 5.13.
A quantity must be committed before a single selling period begins, while the period demand is random and is assumed normally distributed with mean and standard deviation . Both directions of error are penalized. The overage cost is charged per unit left in stock at the end of the period; the underage cost is charged per unit of demand that could not be satisfied. In the situation that named the model, a newsboy buys copies at 25 cents and sells them at 75 cents with no salvage value, so and .
For a realized demand the cost is when and when , which is
the function newsboyLoss. The quantity to be minimized is its expectation under the demand
distribution,
which is newsboyCost. The demand law itself is newsboyDemand m s, the normal distribution
with mean and variance , and newsboyCDF m s S is its distribution function
evaluated at . The file also records that newsboyDemand m s
unfolds to Mathlib's Gaussian and that it is a probability measure, so that measure-theoretic
typeclass search sees through the abbreviation.
One auxiliary function carries the closed-form evaluation of . The standard normal loss function
measures the expected shortfall of a standard normal variable beyond the level ; it is tabulated in the book's Appendix 2 and recurs throughout its treatment of reorder points.
Formalization Note The demand law is Mathlib's gaussianReal m (s^2).toNNReal, which is
the Dirac mass at when ; every statement below assumes . newsboyCDF is
Mathlib's cdf, that is , which for a nondegenerate normal law agrees with
. The costs and are not constrained in the definitions; positivity is
a hypothesis of each theorem.
import Mathlib
open MeasureTheory ProbabilityTheory
namespace InventoryControl
/-- The realized cost of the newsboy model: having ordered `S` and seen period demand `x`, the
cost is `co` per unit left unsold and `cu` per unit of demand that could not be met.
Axsäter, *Inventory Control*, Eq. (5.87)-(5.88). -/
noncomputable def newsboyLoss (co cu S x : ℝ) : ℝ := co * max (S - x) 0 + cu * max (x - S) 0
/-- The period demand: normally distributed with mean `m` and standard deviation `s`.
Axsäter, *Inventory Control*, Sect. 5.13. -/
noncomputable def newsboyDemand (m s : ℝ) : Measure ℝ := gaussianReal m (Real.toNNReal (s ^ 2))
@[simp] lemma newsboyDemand_eq (m s : ℝ) :
newsboyDemand m s = gaussianReal m (Real.toNNReal (s ^ 2)) := rfl
instance instIsProbabilityMeasureNewsboyDemand (m s : ℝ) :
IsProbabilityMeasure (newsboyDemand m s) := by
rw [newsboyDemand_eq]; infer_instance
/-- The expected cost of ordering `S`. Axsäter, *Inventory Control*, Eq. (5.89). -/
noncomputable def newsboyCost (co cu m s S : ℝ) : ℝ :=
∫ x, newsboyLoss co cu S x ∂(newsboyDemand m s)
/-- The demand distribution function, i.e. `Φ((S - m)/s)`, the left-hand side of Eq. (5.91). -/
noncomputable def newsboyCDF (m s S : ℝ) : ℝ := cdf (newsboyDemand m s) S
/-- The standard normal loss function `G(x) = ∫_x^∞ (v - x) φ(v) dv`.
Axsäter, *Inventory Control*, Eq. (5.40) and Appendix 2. -/
noncomputable def normalLoss (x : ℝ) : ℝ :=
∫ v in Set.Ioi x, (v - x) * gaussianPDFReal 0 1 v
end InventoryControl