Skip to content

做什么(One-liner)

基于变异系数的稳定性打分,范围 [0, 1]。库级 primitive。

怎么用

python
from services.algo.statistics import stability_score
stability_score([100, 100, 100, 100])   # 1.0(极稳)
stability_score([100, 50, 150, 80])     # ~0.2(不稳)

核心公式

mean = avg(series)
cv = std(series, ddof=0) / mean
stability = clip(1 - cv × 5, 0, 1)

假设与适用场景

假设:mean > 0 + 系数 5 经验合理 + ddof=0。

适用:收入 / 利润 / ROE 稳定性打分。

不适用:mean ≈ 0、负数、n<2。

已知局限

  1. 系数 5 硬编码
  2. mean 接近 0 失义
  3. 无 robust 变体

参考文献

Pearson (1895) 变异系数 + Pangura 经验 heuristic。

Golden Test

tests/golden/fixtures/tier1/stability_score/,1e-12,2026-04-20 passing。

Changelog

  • 1.0.0 (2026-04-20) — 首次 Active

Verifiable intelligence for the decisions that demand scrutiny.