关于「尺码曲线的狄利克雷—多项式先验:在总部经验与门店样本之间加权」,《季前订货临界分位母典》给出的定量结论是什么?
结论:结果给经营者一个清醒的提醒。只有 12 家门店、共 720 件销售时,估计值是 139.0,区间下端 49.6,上端不封闭:数据只能排除「先验很弱」,却说不出先验有多强。对数似然的差也显示这一点:先验强度 10 比 40 差了 16.922 个对数单位,可以排除;先验强度 160 反而比 40 好 3.036,无法区分。门店增加到 48 家,估计值 56.1,区间 39.0 到 85.9;到 192 家,估计值 43.9,区间 37.1 到 52.1,才把真实值稳稳框住。
数据口径:书中的商品、门店与需求参数均为示意;全部计算由书中程序生成;本书是非个人化经营建议。 第一章用边际算术推出临界分位,示意参数下只有毛利率恰为 0.3750 时最优订量才等于平均数,毛利八成的商品按平均数订会少赚 6.96 %;据施韦策与卡雄实验的已发表数据重建,受试者把订量向平均数拉了 0.644(高利润)与 0.787(低利润)的距离。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 10, 12, 139.0, 160, 192, 3.036
| stores units EB A0 | 95% profile band ll10-ll40 ll160-ll40 |
| 12 | 720 139.0 49.6 to open -16.922 3.036 |
| 48 | 2880 56.1 39.0 to 85.9 -50.707 -7.198 |
| 192 11520 | 43.9 37.1 to 52.1 -168.756 -63.573 |
| true A0 | 40; band = A0 with log-lik within 1.92 of max |
查看完整验算程序
# Chapter 3. p32: Estimating the prior strength A0 by empirical Bayes.
# Synthetic stores: each store's true curve ~ Dirichlet(40 b),
# each sells 60 units, counts multinomial. For a grid of A0 we compute
# the Dirichlet-multinomial log marginal likelihood
# sum_s [lgG(A0) - lgG(A0 + N_s) + sum_k (lgG(A0 b_k + n_sk)
# - lgG(A0 b_k))]
# with b the pooled share; golden search for the maximiser and a
# profile band. True A0 = 40 is hidden from the estimator. Fixed seed.
import math
import random
rng = random.Random(20261112)
BASE = (0.08, 0.22, 0.34, 0.24, 0.12)
TRUE_A0, PER = 40.0, 60
lg = math.lgamma
def dirichlet(alpha):
g = [rng.gammavariate(a, 1.0) for a in alpha]
s = math.fsum(g)
return [x / s for x in g]
def multinomial(p, n):
c = [0] * len(p)
for _ in range(n):
u, acc = rng.random(), 0.0
for k, pk in enumerate(p):
acc += pk
if u < acc or k == len(p) - 1:
c[k] += 1
break
return c
def fit(stores):
data = [multinomial(dirichlet([TRUE_A0 * x for x in BASE]), PER)
for _ in range(stores)]
tot = [math.fsum(s[k] for s in data) for k in range(len(BASE))]
grand = math.fsum(tot)
b = [t / grand for t in tot]
def loglik(a0):
parts = []
for s in data:
parts.append(lg(a0) - lg(a0 + math.fsum(s)))
for k, nk in enumerate(s):
parts.append(lg(a0 * b[k] + nk) - lg(a0 * b[k]))
return math.fsum(parts)
lo, hi = math.log(2.0), math.log(5000.0)
r = (math.sqrt(5.0) - 1.0) / 2.0
for _ in range(80):
x1, x2 = hi - r * (hi - lo), lo + r * (hi - lo)
if loglik(math.exp(x1)) > loglik(math.exp(x2)):
hi = x2
else:
lo = x1
best = loglik(math.exp(lo))
grid = [math.exp(math.log(2.0) + i * 0.01) for i in range(800)]
inside = [a for a in grid if loglik(a) >= best - 1.92]
return math.exp(lo), inside[0], inside[-1], [loglik(a) for a in
(10.0, 40.0, 160.0)]
print("stores units EB A0 95% profile band ll10-ll40 ll160-ll40")
for stores in (12, 48, 192):
a0, lo, hi, ll = fit(stores)
top = "{:7.1f}".format(hi) if hi < 5000.0 else " open"
print("{:6d} {:5d} {:6.1f} {:6.1f} to {} {:10.3f} {:10.3f}"
.format(stores, stores * PER, a0, lo, top, ll[0] - ll[1],
ll[2] - ll[1]))
print("true A0 = {:.0f}; band = A0 with log-lik within 1.92 of max"
.format(TRUE_A0))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《买手季前订货报童临界分位、尺码曲线狄利克雷先验与季末降价动态规划母典》第 3 章「尺码曲线的狄利克雷—多项式先验:在总部经验与门店样本之间加权」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-211 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026211,
author = {Fan, Yafu},
title = {Newsvendor Critical Fractiles for Pre-Season Buying, Dirichlet Size-Curve Priors and Dynamic-Programming End-of-Season Markdowns},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}