STEP 1376 — Welch t-test primitive + sample-pair verdict v0.1
1. 契機
chat-Claude 2026-08-22: 「benchtop-mcp も 同じで、 実機の 測定値には 必ず ノイズが 乗るので、 2 回の 測定が 「違う」 のか 「同じ値の ばらつき」 なのかを 言える機械が 要ります。」
藤本さん directive defer 5 項目 (c) Welch-t 統合 の 実装。 STEP 1358 (Statistics × NEITHER Education v0.2) の JavaScript 実装 (twoSampleTTest + studentTCdf + incompleteBeta + logGamma) を TypeScript primitive として src/mcp/d8-verdict-mapping.ts に extract、 MCP tool d8_verdict_from_sample_pair として wire up。
SAC-4 46 例目: 初稿 STEP 1375 → 別タブ 4 repo public publish arc 同時 claim 判明 → **STEP 1376** に renumber (同日 4 度目 collision、 code 内 4 refs 全一括処理)。
2. 実装内容
2.1 src/mcp/d8-verdict-mapping.ts 追加 export 5
welchTTest(sample1, sample2)— Welch t-test primitive、 返却{t, df, pValue, mean1, mean2, variance1, variance2, sampleSize1, sampleSize2, effectSizeCohenD}。 Welch-Satterthwaite df + two-sided p-value + Cohen's d (pooled SD 分母)studentTCdf(t, df)— Student t CDF (Abramowitz-Stegun 26.7.8、 regularized incomplete beta 経由)mapSamplePairToD8(input)— 決定表 S1-S6 で D-FUMT₈ verdict mappingd8SamplePairSpecTable()— spec-as-data dump- Internal:
logGamma(Lanczos g=7 9 coefficients IEEE double 精度) +incompleteBeta(Lentz's method、 200 iter cap)
2.2 決定表 (S1-S6、 first-match priority)
| # | Condition | Verdict | Reason |
|---|---|---|---|
| S1 | sample1.length < 2 or sample2.length < 2 | NEITHER N | insufficient_sample |
| S2 | alpha null/NaN/≤0/≥1 | NEITHER N | alpha_not_set |
| S3 | variance both zero + means equal | FALSE ⊥ | zero_variance_zero_diff |
| S4 | variance both zero + means differ | INFINITY ∞ | deterministic_difference |
| S5 | p < alpha | TRUE ⊤ | significant_effect |
| S6 | p ≥ alpha | FALSE ⊥ | no_significant_effect |
v0.1 activate: 4/8 値 (TRUE / FALSE / NEITHER / INFINITY)。 BOTH / ZERO / FLOWING / SELF は 予約 (v0.2 で 「有意だが 微小」 = BOTH 活用予定、 Cohen's d threshold 統合)。
2.3 STEP 1350 / 1371 との 相補関係
| STEP | Domain | Activate |
|---|---|---|
| 1350 | 単一測定 (single sensor) | TRUE / NEITHER / ZERO / INFINITY / FLOWING (5/8) |
| 1371 | 多試行 集約 (multi-trial FDR) | TRUE / NEITHER / ZERO / FALSE / BOTH (5/8) |
| 1376 (本 STEP) | sample-pair (Welch t-test) | TRUE / FALSE / NEITHER / INFINITY (4/8) |
| 合計 | — | 7/8 (SELF のみ 予約) |
2.4 pipeline 連携 (STEP 1371 との integration)
複数 pair measurements
→ welchTTest × N
→ {id, pValue} × N
→ mapMultiTrialToD8({trials, fdrQ, alpha})
→ 多試行 FDR 集約 verdict
test [13] で 10 pair-tests → naive=5, fdr=5, verdict=TRUE を 実測 confirm。
3. Verify 実測
3.1 test 65/65 PASS (16 part)
- [1] Student t CDF 教科書 critical values (t=1.96/df=100→p≈0.053、t=2.0/df=30→p≈0.055、t=1.645/df=1000→p≈0.10)
- [2] welchTTest 対称 shift x=[1..5], y=[3..7] → t=-2.0, df=8.0, p≈0.081, Cohen's d≈-1.27
- [3] identical samples → t=0, p=1, Cohen's d=0
- [4]-[5] zero variance boundary cases
- [6] unequal variances (classic Welch case)
- [7]-[12] Rule S1-S6 全網羅
- [13] STEP 1371 pipeline: 10 pair-tests → BH FDR aggregate verdict = TRUE (naive=5, fdr=5)
- [14]-[16] spec table + source marker + invalid input rejection
3.2 MCP stdio end-to-end smoke
call: d8_verdict_from_sample_pair(sample1=[1..10], sample2=[11..20], alpha=0.05) → verdict = TRUE, reason = significant_effect → t = -7.385, df = 18, pValue = 7.5e-7 → Cohen's d = -3.30 (huge effect) → source = 'welch-t-sample-pair-verdict-mapping' ✓ → honestScope embedded ✓
3.3 Regression + banner
- Tool count: 41 (was 40 + 1)、banner: v2.8.3 (was v2.8.2)
- STEP 1371/1350 primitive test 89/89 + 77/77 regression clean (無変更)
4. Honest scope
- 「世界初」 主張ゼロ ([[feedback-world-uniqueness-claim-controllable]])。 Welch 1938 + Satterthwaite 1946 = 80+ 年前既知、 Numerical Recipes 参照実装、 novelty は 「D-FUMT₈ 8 値 verdict layer への mapping + STEP 1350/1371 相補構造 + Rei stack 内 primitive 統合」 のみ
- v0.1 = two-sample Welch のみ、 paired t / one-sample / ANOVA / permutation は 別 STEP
- Cohen's d 効果量は 計算 + 返却 のみ、 verdict 判定には 未使用 (v0.2 で 「有意だが |d|<0.2 微小」 = BOTH 経路 追加検討)
- Student t CDF は Abramowitz-Stegun 26.7.8 approximation、 教育目的で 十分精度、 極端 tail (p<1e-15) では 別 実装検討
- 順序原則 operational form: alpha 引数注入強制、 定数化禁止 (pre-registration STEP 1359 rei-preregister 連携候補)
- Rei stack MCP 8 systems 数不変 (rei-aios 内 tool 40→41)
- defer (c) 完了、 残 (b) discovery-worker Python adapter は STEP 1377 別 arc
5. 関連
- STEP 1350 (2026-08-20) — 単一測定 verdict、 相補 domain
- STEP 1358 (2026-08-21) — Statistics × NEITHER Education v0.2、 本 STEP 実装源
- STEP 1371 (2026-08-22) — 多試行 FDR aggregate、 本 STEP 出力の pipeline 連携先
- STEP 1372 (2026-08-23) — MCP wrapper pattern mirror 元
- STEP 1374 (2026-08-23) — MEMORY compact + CLAUDE catch-up
feedback_all_research_site_reflection_default— 2026-08-06 protocol 継続