Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The newsboy model with normally distributed demand

Definition
InventoryControl_newsboy

by naimengye · Sep 18, 2026 · Mathlib 0df444a (Lean v4.33.1)

inventory-controlnewsvendoroperations-researchprobability

The classical single-period stochastic inventory problem, in the notation of Axsäter, Inventory Control, Sect. 5.13.

A quantity SSS must be committed before a single selling period begins, while the period demand xxx is random and is assumed normally distributed with mean mmm and standard deviation sss. Both directions of error are penalized. The overage cost coc_oco​ is charged per unit left in stock at the end of the period; the underage cost cuc_ucu​ 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 co=25c_o = 25co​=25 and cu=75−25=50c_u = 75 - 25 = 50cu​=75−25=50.

For a realized demand xxx the cost is (S−x)co(S - x)c_o(S−x)co​ when x<Sx < Sx<S and (x−S)cu(x - S)c_u(x−S)cu​ when x>Sx > Sx>S, which is

ℓ(S,x)  =  co(S−x)++cu(x−S)+,\ell(S, x) \;=\; c_o (S-x)^{+} + c_u (x-S)^{+} ,ℓ(S,x)=co​(S−x)++cu​(x−S)+,

the function newsboyLoss. The quantity to be minimized is its expectation under the demand distribution,

C(S)  =  E ⁣[ℓ(S,x)],C(S) \;=\; \mathbb{E}\!\left[\ell(S, x)\right] ,C(S)=E[ℓ(S,x)],

which is newsboyCost. The demand law itself is newsboyDemand m s, the normal distribution with mean mmm and variance s2s^{2}s2, and newsboyCDF m s S is its distribution function Φ ⁣((S−m)/s)\Phi\!\left((S-m)/s\right)Φ((S−m)/s) evaluated at SSS. 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 CCC. The standard normal loss function

G(x)  =  ∫x∞(v−x) φ(v) dvG(x) \;=\; \int_{x}^{\infty} (v - x)\,\varphi(v)\,\mathrm{d}vG(x)=∫x∞​(v−x)φ(v)dv

measures the expected shortfall of a standard normal variable beyond the level xxx; 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 mmm when s=0s = 0s=0; every statement below assumes s>0s > 0s>0. newsboyCDF is Mathlib's cdf, that is Pr⁡[x≤S]\Pr[x \le S]Pr[x≤S], which for a nondegenerate normal law agrees with Pr⁡[x<S]\Pr[x < S]Pr[x<S]. The costs coc_oco​ and cuc_ucu​ are not constrained in the definitions; positivity is a hypothesis of each theorem.

Definition code
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
Source
Sven Axsäter, Inventory Control, 3rd ed., Springer 2015, DOI 10.1007/978-3-319-15729-0, Sect. 5.13 'The Newsboy Model', pp. 95-96 (Eq. 5.87-5.89); the standard normal loss function is Eq. (5.40) p. 77 and Appendix 2 p. 242

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me