## 审查结论 算法移植是对的:大样本正态下百分位区间半宽与解析 `2 × 1.96 × se` 差 < 2%, 按块重采样(batch_size=1000)也照 docstring 的 Notes 做了。以下是要改的部分。 ## Fixed - `random_state=None` 时另开 `np.random.default_rng()`,**绕过了 `core.get_rng`** —— 与决策 24 冲突:`set_seed` 对它无效,同一段脚本重跑区间就变。改成无条件 `get_rng(random_state)`(决策 46)。 - `metrics["statistic_name"]` 用 `hasattr(statistic, "__name__")` 判不出 lambda: lambda 的 `__name__` 恒为 `"<lambda>"`,于是 `else "custom"` 是**死代码**, 实测自定义统计量拿到的是 `"<lambda>"`。改成 `getattr(f, "__name__", None)` + 判 `"<lambda>"`(易错点 17)。 - docstring 补齐 `Parameters` / `Returns` / `Raises`(§4.7),并如实写明 `method="bca"` **尚未实现** (此前 docstring 承诺支持、实现却抛 `NotImplementedError`)。 - ruff 两条:I001(导入块拆成三行且用了绝对导入)、F541(`f"暂不支持bca"` 无占位符)。 ## Tests - **摘掉 3 条 `skip`**:等 `bootstrap_ci` 的那 3 条一直挂着,实现写完照样全绿 —— 易错点 9 复发, 已在 `personal-pitfalls.md` 把该条 `复发` 记到 1 并注明本次经过。 - 新增 6 条:`estimate` 等于原样本统计量、`confidence` 单调性、五种容器一致、 自定义 lambda 走回退分支、**不给种子时跟随 `set_seed`**(钉住上面那个 rng 修复)、非法/未实现 method。 - 写测试时踩到一个真性质:极差的重采样值**永远 ≤ 原样本极差**,`high` 会正好等于 `estimate`, 断言不能写 `estimate < high`。这条已写进卡片 §5。 - 全量 **177 条:143 passed / 34 skipped / 0 xfail**;ruff 0,pyright 0;`examples/01` 跑通。 ## Docs - `docs/algorithms/bootstrap_ci.md`:**第 2 张 S 档卡片**(模板九节 + §10 待拍板)。 `docs/algorithms/README.md` 进度表打勾。 - `docs/dev/personal-pitfalls.md`:新增第 17 条(`hasattr(f, "__name__")` 挡不住 lambda,`else` 分支即死代码), 索引补到 17;第 9 条记一次复发。 - `STATUS.md`:E 节记 `bootstrap_ci`(L0 10/12 → 剩余 `monte_carlo` `save_figure`),决策 46, 「下一步」第 1 条改写、新增第 8 条列 5 个待拍板口径。 ## 待用户拍板(Codex 一律未动,按决策 39) - `x` 里的 NaN 静默传进统计量 → `nan` 区间(`confidence_interval` / `t_test` 都是先丢 NaN 的,口径不齐) - `n_resamples <= 0` 现在抛 `IndexError: index -1 is out of bounds`(应在入口给可读 ValueError) - `confidence` 越界交给 numpy 抛 `Percentiles must be in the range [0, 100]` - `method="bca"`:补实现(≈25 行,S 档)还是从 docstring 删掉 - `bootstrap_statistic` 仍是 `NotImplementedError`,而 `bootstrap_ci` 把那段重采样循环内联了 —— 建议抽出去让 `bootstrap_ci` 调它(易错点 16 的变体)
27 lines
1.3 KiB
Markdown
27 lines
1.3 KiB
Markdown
# 算法卡片
|
|
|
|
S 档(自己实现的招牌算法)的**函数卡片**放这里,模板见
|
|
[`../dev/function-card-template.md`](../dev/function-card-template.md)。
|
|
|
|
计划要写的卡片(见 `../03-roadmap.md` §3.1,约 15 张):
|
|
|
|
| 卡片 | 对应函数 | 状态 |
|
|
|---|---|---|
|
|
| `detect_outliers.md` | `data.detect_outliers` | ✅ 2026-10-02 |
|
|
| `bootstrap_ci.md` | `stats.bootstrap_ci` | ✅ 2026-10-03(§10 有 5 个口径待拍板)|
|
|
| `monte_carlo.md` | `solve.monte_carlo` | ⬜ |
|
|
| `monte_carlo_probability.md` | `solve.monte_carlo_probability` | ⬜ |
|
|
| `monte_carlo_integral.md` | `solve.monte_carlo_integral` | ⬜ |
|
|
| `dynamic_programming.md` | `solve.dynamic_programming` | ⬜ |
|
|
| `knapsack_dp.md` | `solve.knapsack_dp` | ⬜ |
|
|
| `simulated_annealing.md` | `solve.simulated_annealing` | ⬜ |
|
|
| `local_sensitivity.md` | `solve.local_sensitivity` | ⬜ |
|
|
| `sobol_analyze.md` | `solve.sobol_analyze` | ⬜ |
|
|
| `entropy_weights.md` | `decision.entropy_weights` | ⬜ |
|
|
| `topsis.md` | `decision.topsis` | ⬜ |
|
|
| `ahp_weights.md` | `decision.ahp_weights` | ⬜ |
|
|
| `gm11_fit_predict.md` | `decision.gm11_fit_predict` | ⬜ |
|
|
|
|
> 卡片是写给自己半年后看的,不是给评审看的。
|
|
> 如果一张卡片最后只复述了 docstring,说明这个函数其实是 A 档,应该降档删卡片。
|