@tangle-network/agent-eval 1.0.19 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -27
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-CPv4tENR.d.ts → agent-profile-BO8ruI6R.d.ts} +3 -3
- package/dist/{agent-profile-CPv4tENR.d.ts.map → agent-profile-BO8ruI6R.d.ts.map} +1 -1
- package/dist/analyst/index.d.ts +14 -14
- package/dist/analyst/index.js +11 -12
- package/dist/analyst/index.js.map +1 -1
- package/dist/{analyze-runs-pJ4fhnYg.d.ts → analyze-runs-DYYe18Gw.d.ts} +4 -4
- package/dist/{analyze-runs-pJ4fhnYg.d.ts.map → analyze-runs-DYYe18Gw.d.ts.map} +1 -1
- package/dist/{analyze-runs-C7vWBDhl.js → analyze-runs-jLTRKuoK.js} +6 -110
- package/dist/analyze-runs-jLTRKuoK.js.map +1 -0
- package/dist/app-grade/index.d.ts +4 -4
- package/dist/app-grade/index.js +3 -3
- package/dist/{benchmark-command-DSJQeYom.js → benchmark-command-CoNndRCk.js} +13 -14
- package/dist/benchmark-command-CoNndRCk.js.map +1 -0
- package/dist/benchmarks/index.d.ts +4 -4
- package/dist/benchmarks/index.js +4 -5
- package/dist/benchmarks/index.js.map +1 -1
- package/dist/builder-eval/index.js +1 -1
- package/dist/{calibration-CbZPApIO.js → calibration-Cf-wpqqO.js} +2 -2
- package/dist/{calibration-CbZPApIO.js.map → calibration-Cf-wpqqO.js.map} +1 -1
- package/dist/campaign/index.d.ts +7 -7
- package/dist/campaign/index.js +10 -10
- package/dist/{campaign-BABipFel.js → campaign-Bl07uIaf.js} +14 -15
- package/dist/{campaign-BABipFel.js.map → campaign-Bl07uIaf.js.map} +1 -1
- package/dist/{campaign-evidence-DONEWvVY.js → campaign-evidence-NtH29ctt.js} +3 -3
- package/dist/{campaign-evidence-DONEWvVY.js.map → campaign-evidence-NtH29ctt.js.map} +1 -1
- package/dist/{chat-client-D0me8iwq.js → chat-client-Zz97O3NB.js} +2 -2
- package/dist/{chat-client-D0me8iwq.js.map → chat-client-Zz97O3NB.js.map} +1 -1
- package/dist/{chat-json-call-C473CwTt.js → chat-json-call-Dgi7-RH-.js} +2 -2
- package/dist/{chat-json-call-C473CwTt.js.map → chat-json-call-Dgi7-RH-.js.map} +1 -1
- package/dist/cli.js +7 -7
- package/dist/{types-0KglnQ9o.d.ts → cluster-Cd0MRbr9.d.ts} +44 -2
- package/dist/cluster-Cd0MRbr9.d.ts.map +1 -0
- package/dist/cluster-bootstrap-B0MTOBRU.js +24 -0
- package/dist/cluster-bootstrap-B0MTOBRU.js.map +1 -0
- package/dist/{completion-verifier-7KEfroqx.d.ts → completion-verifier-BEpsr3N4.d.ts} +2 -2
- package/dist/{completion-verifier-7KEfroqx.d.ts.map → completion-verifier-BEpsr3N4.d.ts.map} +1 -1
- package/dist/{completion-verifier-ClmJV_Yc.js → completion-verifier-DFyYFezn.js} +3 -3
- package/dist/{completion-verifier-ClmJV_Yc.js.map → completion-verifier-DFyYFezn.js.map} +1 -1
- package/dist/contract/index.d.ts +10 -10
- package/dist/contract/index.js +14 -15
- package/dist/contract/index.js.map +1 -1
- package/dist/{cost-ledger-CS8R3IZj.js → cost-ledger-DfhStGcZ.js} +2 -2
- package/dist/{cost-ledger-CS8R3IZj.js.map → cost-ledger-DfhStGcZ.js.map} +1 -1
- package/dist/{decision-point-CNyoKOkz.js → decision-point-Di2LATNH.js} +4 -4
- package/dist/{decision-point-CNyoKOkz.js.map → decision-point-Di2LATNH.js.map} +1 -1
- package/dist/{default-registry-BB9_jzyH.js → default-registry-CdFbxPnr.js} +5 -5
- package/dist/{default-registry-BB9_jzyH.js.map → default-registry-CdFbxPnr.js.map} +1 -1
- package/dist/{default-registry-BbXr18AT.d.ts → default-registry-aPvwtzEM.d.ts} +7 -7
- package/dist/{default-registry-BbXr18AT.d.ts.map → default-registry-aPvwtzEM.d.ts.map} +1 -1
- package/dist/{define-agent-eval-Q4FdXGj7.js → define-agent-eval-BROmIwn1.js} +6 -6
- package/dist/{define-agent-eval-Q4FdXGj7.js.map → define-agent-eval-BROmIwn1.js.map} +1 -1
- package/dist/{define-agent-eval-D_DQMH04.d.ts → define-agent-eval-Bx3b9B01.d.ts} +7 -7
- package/dist/{define-agent-eval-D_DQMH04.d.ts.map → define-agent-eval-Bx3b9B01.d.ts.map} +1 -1
- package/dist/diagnosis/index.d.ts +2 -2
- package/dist/diagnosis/index.js +1 -1
- package/dist/{dspy-rlm-engine-CqQc0R2l.js → dspy-rlm-engine-cWyn8G1a.js} +4 -4
- package/dist/{dspy-rlm-engine-CqQc0R2l.js.map → dspy-rlm-engine-cWyn8G1a.js.map} +1 -1
- package/dist/{engine-rfV8Ff8V.d.ts → engine-BF8naBn7.d.ts} +2 -2
- package/dist/{engine-rfV8Ff8V.d.ts.map → engine-BF8naBn7.d.ts.map} +1 -1
- package/dist/{eval-campaign-CZSCjxVb.js → eval-campaign-Dq8DEKmy.js} +2 -2
- package/dist/{eval-campaign-CZSCjxVb.js.map → eval-campaign-Dq8DEKmy.js.map} +1 -1
- package/dist/{evaluation-SDXKL6Fx.d.ts → evaluation-CFKj_IlJ.d.ts} +4 -4
- package/dist/{evaluation-SDXKL6Fx.d.ts.map → evaluation-CFKj_IlJ.d.ts.map} +1 -1
- package/dist/{evaluation-BBI37mRe.js → evaluation-bU_bhlv-.js} +2 -2
- package/dist/{evaluation-BBI37mRe.js.map → evaluation-bU_bhlv-.js.map} +1 -1
- package/dist/evaluation.d.ts +1 -1
- package/dist/evaluation.js +1 -1
- package/dist/{exact-types-CaLLU1Pz.d.ts → exact-types-VAFjtOQN.d.ts} +2 -2
- package/dist/{exact-types-CaLLU1Pz.d.ts.map → exact-types-VAFjtOQN.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +3 -5
- package/dist/experiment/index.d.ts.map +1 -1
- package/dist/experiment/index.js +7 -12
- package/dist/experiment/index.js.map +1 -1
- package/dist/{exporters-BYBG9b1n.d.ts → exporters-dQKYD_Zo.d.ts} +2 -2
- package/dist/{exporters-BYBG9b1n.d.ts.map → exporters-dQKYD_Zo.d.ts.map} +1 -1
- package/dist/{external-optimizer-process-CfrY-nJT.js → external-optimizer-process-2ImGH_LR.js} +2 -2
- package/dist/{external-optimizer-process-CfrY-nJT.js.map → external-optimizer-process-2ImGH_LR.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-BtJk8UcU.js → external-optimizer-subprocess-_C_2yriN.js} +3 -3
- package/dist/{external-optimizer-subprocess-BtJk8UcU.js.map → external-optimizer-subprocess-_C_2yriN.js.map} +1 -1
- package/dist/{feedback-trajectory-P37ju-gW.d.ts → feedback-trajectory-DTj8eVTR.d.ts} +3 -3
- package/dist/{feedback-trajectory-P37ju-gW.d.ts.map → feedback-trajectory-DTj8eVTR.d.ts.map} +1 -1
- package/dist/{findings-store-BnYN57-h.js → findings-store-BSuaV3dN.js} +7 -24
- package/dist/findings-store-BSuaV3dN.js.map +1 -0
- package/dist/fuzz.js +2 -2
- package/dist/{index-D4lT7aFu.d.ts → index-7tWvC0aW.d.ts} +28 -128
- package/dist/index-7tWvC0aW.d.ts.map +1 -0
- package/dist/{index-C3t17kHu.d.ts → index-B62BaRzH.d.ts} +7 -100
- package/dist/index-B62BaRzH.d.ts.map +1 -0
- package/dist/{index-HuSMvqR2.d.ts → index-BlTbxHlY.d.ts} +5 -5
- package/dist/{index-HuSMvqR2.d.ts.map → index-BlTbxHlY.d.ts.map} +1 -1
- package/dist/{index-AmfM3usI.d.ts → index-CM12lr9E.d.ts} +8 -8
- package/dist/{index-AmfM3usI.d.ts.map → index-CM12lr9E.d.ts.map} +1 -1
- package/dist/{index-DLVbfss9.d.ts → index-DFso1b2W.d.ts} +8 -8
- package/dist/{index-DLVbfss9.d.ts.map → index-DFso1b2W.d.ts.map} +1 -1
- package/dist/index-DNXFzSpc.d.ts +1101 -0
- package/dist/index-DNXFzSpc.d.ts.map +1 -0
- package/dist/{index-BPmj-_ta.d.ts → index-DfqAy8ct.d.ts} +10 -9
- package/dist/index-DfqAy8ct.d.ts.map +1 -0
- package/dist/index.d.ts +29 -31
- package/dist/index.js +28 -164
- package/dist/index.js.map +1 -1
- package/dist/{integrity-BAdVzT8u.d.ts → integrity-CrmnGB2T.d.ts} +2 -2
- package/dist/{integrity-BAdVzT8u.d.ts.map → integrity-CrmnGB2T.d.ts.map} +1 -1
- package/dist/{judge-gate-CIlBrn6q.js → judge-gate-CrN0PaAL.js} +3 -3
- package/dist/{judge-gate-CIlBrn6q.js.map → judge-gate-CrN0PaAL.js.map} +1 -1
- package/dist/{kind-factory-Cfz8DUCc.js → kind-factory-CV0FNCMM.js} +2 -2
- package/dist/{kind-factory-Cfz8DUCc.js.map → kind-factory-CV0FNCMM.js.map} +1 -1
- package/dist/{llm-client-BdSiZ4qz.js → llm-client-DMMSg-Ro.js} +2 -2
- package/dist/{llm-client-BdSiZ4qz.js.map → llm-client-DMMSg-Ro.js.map} +1 -1
- package/dist/{llm-judge-VD_MI6kd.js → llm-judge-C813vmpc.js} +13 -14
- package/dist/{llm-judge-VD_MI6kd.js.map → llm-judge-C813vmpc.js.map} +1 -1
- package/dist/{matrix-Yg1lHIGI.d.ts → matrix-C-GxIgeJ.d.ts} +2 -2
- package/dist/{matrix-Yg1lHIGI.d.ts.map → matrix-C-GxIgeJ.d.ts.map} +1 -1
- package/dist/meta-eval/index.d.ts +2 -2
- package/dist/meta-eval/index.js +7 -7
- package/dist/{metrics-DNCAUtuB.js → metrics-zALlR17s.js} +16 -17
- package/dist/metrics-zALlR17s.js.map +1 -0
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +2 -2
- package/dist/multishot/index.js +1 -1
- package/dist/openapi.json +1 -1
- package/dist/{outcome-observations-DZu5hLYF.js → outcome-observations-DPkH-LHQ.js} +2 -3
- package/dist/{outcome-observations-DZu5hLYF.js.map → outcome-observations-DPkH-LHQ.js.map} +1 -1
- package/dist/paired-arms-DjMEtYI9.js +338 -0
- package/dist/paired-arms-DjMEtYI9.js.map +1 -0
- package/dist/{paired-promotion-decision-CiueaTTj.js → paired-promotion-decision-Bi9__RQS.js} +2 -3
- package/dist/{paired-promotion-decision-CiueaTTj.js.map → paired-promotion-decision-Bi9__RQS.js.map} +1 -1
- package/dist/{paired-promotion-decision-BDnqepZ1.d.ts → paired-promotion-decision-DJU3fZxH.d.ts} +3 -113
- package/dist/paired-promotion-decision-DJU3fZxH.d.ts.map +1 -0
- package/dist/{pareto-a3EOmjfe.js → pareto-fJZg8pXm.js} +3 -6
- package/dist/{pareto-a3EOmjfe.js.map → pareto-fJZg8pXm.js.map} +1 -1
- package/dist/pipelines/index.js +1 -1
- package/dist/{prime-protocol-DKRk4l4U.d.ts → prime-protocol-D1NkJRuD.d.ts} +2 -2
- package/dist/{prime-protocol-DKRk4l4U.d.ts.map → prime-protocol-D1NkJRuD.d.ts.map} +1 -1
- package/dist/{promotion-gate-DOkgJcLW.d.ts → promotion-gate-Da0xV4sa.d.ts} +3 -67
- package/dist/promotion-gate-Da0xV4sa.d.ts.map +1 -0
- package/dist/{promotion-policy-DLPcEnCf.js → promotion-policy-DCgftbnd.js} +4 -4
- package/dist/{promotion-policy-DLPcEnCf.js.map → promotion-policy-DCgftbnd.js.map} +1 -1
- package/dist/{proposal-findings-BfzzZ_lN.js → proposal-findings-DWs94yT8.js} +2 -2
- package/dist/{proposal-findings-BfzzZ_lN.js.map → proposal-findings-DWs94yT8.js.map} +1 -1
- package/dist/{registry-Ck7w-rr5.d.ts → registry-BAcEbzKm.d.ts} +4 -4
- package/dist/{registry-Ck7w-rr5.d.ts.map → registry-BAcEbzKm.d.ts.map} +1 -1
- package/dist/{release-confidence-nfQNh3eb.js → release-confidence-DGtuPDxJ.js} +2 -2
- package/dist/{release-confidence-nfQNh3eb.js.map → release-confidence-DGtuPDxJ.js.map} +1 -1
- package/dist/reporting.d.ts +4 -5
- package/dist/reporting.d.ts.map +1 -1
- package/dist/reporting.js +5 -7
- package/dist/reporting.js.map +1 -1
- package/dist/{researcher-CLnNJ7Or.d.ts → researcher-CSlc84Bp.d.ts} +4 -4
- package/dist/{researcher-CLnNJ7Or.d.ts.map → researcher-CSlc84Bp.d.ts.map} +1 -1
- package/dist/{reward-hacking-B88f-Kh7.js → reward-hacking-BYiDFbIl.js} +2 -3
- package/dist/{reward-hacking-B88f-Kh7.js.map → reward-hacking-BYiDFbIl.js.map} +1 -1
- package/dist/rl.d.ts +9 -8
- package/dist/rl.d.ts.map +1 -1
- package/dist/rl.js +8 -10
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +4 -4
- package/dist/rollout/index.js +1 -1
- package/dist/{rollout-Cu7kHGIe.js → rollout-DKa54qer.js} +2 -2
- package/dist/{rollout-Cu7kHGIe.js.map → rollout-DKa54qer.js.map} +1 -1
- package/dist/{rubric-predictive-validity-D_6ZPTNR.js → rubric-predictive-validity-DL7gJ51F.js} +2 -2
- package/dist/{rubric-predictive-validity-D_6ZPTNR.js.map → rubric-predictive-validity-DL7gJ51F.js.map} +1 -1
- package/dist/{run-record-CbUi2adH.js → run-record-CFbnkE1K.js} +2 -2
- package/dist/{run-record-CbUi2adH.js.map → run-record-CFbnkE1K.js.map} +1 -1
- package/dist/{runtime-rollouts-kGn1K5ut.js → runtime-rollouts-BNrm5nC_.js} +2 -2
- package/dist/{runtime-rollouts-kGn1K5ut.js.map → runtime-rollouts-BNrm5nC_.js.map} +1 -1
- package/dist/{schema-CfoA9U_U.d.ts → schema-PDKQ_iNE.d.ts} +2 -131
- package/dist/schema-PDKQ_iNE.d.ts.map +1 -0
- package/dist/search/index.d.ts +2 -2
- package/dist/search/index.js +2 -2
- package/dist/{search-kernel-DjqaPJqL.d.ts → search-kernel-CQGLbmgn.d.ts} +3 -3
- package/dist/{search-kernel-DjqaPJqL.d.ts.map → search-kernel-CQGLbmgn.d.ts.map} +1 -1
- package/dist/{search-summary-RJ5zXjHN.js → search-summary-sPWiYtSl.js} +4 -4
- package/dist/{search-summary-RJ5zXjHN.js.map → search-summary-sPWiYtSl.js.map} +1 -1
- package/dist/{sequential-BPbvgzfe.js → sequential-9TVb5Nu5.js} +3 -3
- package/dist/{sequential-BPbvgzfe.js.map → sequential-9TVb5Nu5.js.map} +1 -1
- package/dist/{sequential-Bb_pdTqG.d.ts → sequential-B9p6uoV8.d.ts} +9 -2
- package/dist/{sequential-Bb_pdTqG.d.ts.map → sequential-B9p6uoV8.d.ts.map} +1 -1
- package/dist/{sequential-Bjs5roiK.js → sequential-CAksw6EU.js} +32 -2
- package/dist/{sequential-Bjs5roiK.js.map → sequential-CAksw6EU.js.map} +1 -1
- package/dist/{server-CPKyf3bz.js → server-DFVwfoZq.js} +3 -3
- package/dist/{server-CPKyf3bz.js.map → server-DFVwfoZq.js.map} +1 -1
- package/dist/{skillopt-optimization-method-D9Hlmhjg.js → skillopt-optimization-method-QO1nU8Kz.js} +9 -9
- package/dist/{skillopt-optimization-method-D9Hlmhjg.js.map → skillopt-optimization-method-QO1nU8Kz.js.map} +1 -1
- package/dist/{statistical-heldout-C-tgpUuu.d.ts → statistical-heldout-CvOwNqt9.d.ts} +6 -282
- package/dist/statistical-heldout-CvOwNqt9.d.ts.map +1 -0
- package/dist/{statistical-heldout-NBxC7jGo.js → statistical-heldout-DLO4Ebos.js} +3 -3
- package/dist/{statistical-heldout-NBxC7jGo.js.map → statistical-heldout-DLO4Ebos.js.map} +1 -1
- package/dist/statistics-CvvC-MPv.js +2634 -0
- package/dist/statistics-CvvC-MPv.js.map +1 -0
- package/dist/statistics.d.ts +3 -0
- package/dist/statistics.js +3 -0
- package/dist/{store-otlp-BfPRa2p8.js → store-otlp-C-jyj3WX.js} +2 -2
- package/dist/{store-otlp-BfPRa2p8.js.map → store-otlp-C-jyj3WX.js.map} +1 -1
- package/dist/{store-tool-spans-BgwVHXma.d.ts → store-tool-spans-B3z_Qb5u.d.ts} +5 -5
- package/dist/{store-tool-spans-BgwVHXma.d.ts.map → store-tool-spans-B3z_Qb5u.d.ts.map} +1 -1
- package/dist/{store-tool-spans-BrSWHB9O.js → store-tool-spans-DalWlKY8.js} +3 -3
- package/dist/{store-tool-spans-BrSWHB9O.js.map → store-tool-spans-DalWlKY8.js.map} +1 -1
- package/dist/{summary-report-C3IJvp0i.js → summary-report-BEhqoxrA.js} +4 -52
- package/dist/summary-report-BEhqoxrA.js.map +1 -0
- package/dist/{summary-report-0La5vejY.d.ts → summary-report-DyZquTaH.d.ts} +2 -2
- package/dist/{summary-report-0La5vejY.d.ts.map → summary-report-DyZquTaH.d.ts.map} +1 -1
- package/dist/supervisor-run/index.d.ts +2 -2
- package/dist/supervisor-run/index.js +1 -1
- package/dist/{systemone-CpDppX8s.d.ts → systemone-DVk-Crtu.d.ts} +7 -7
- package/dist/{systemone-CpDppX8s.d.ts.map → systemone-DVk-Crtu.d.ts.map} +1 -1
- package/dist/{systemone-review-nbuMxxmi.d.ts → systemone-review-CToBl1oa.d.ts} +2 -2
- package/dist/{systemone-review-nbuMxxmi.d.ts.map → systemone-review-CToBl1oa.d.ts.map} +1 -1
- package/dist/systemone.d.ts +3 -3
- package/dist/systemone.js +2 -2
- package/dist/{tool-groups-BQsjZD9F.d.ts → tool-groups-R5RO9OHn.d.ts} +3 -3
- package/dist/tool-groups-R5RO9OHn.d.ts.map +1 -0
- package/dist/{tool-waste-Czt3aWID.js → tool-waste-BqSmmPUz.js} +2 -3
- package/dist/{tool-waste-Czt3aWID.js.map → tool-waste-BqSmmPUz.js.map} +1 -1
- package/dist/{trace-questions-CpTrtEcm.d.ts → trace-questions-BY6taxnl.d.ts} +3 -3
- package/dist/{trace-questions-CpTrtEcm.d.ts.map → trace-questions-BY6taxnl.d.ts.map} +1 -1
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/trace-repair/index.js +1 -2
- package/dist/trace-repair/index.js.map +1 -1
- package/dist/traces.d.ts +5 -5
- package/dist/traces.js +3 -3
- package/dist/{tree-DIHp6UQ0.js → tree-C-N2kP-8.js} +4 -6
- package/dist/{tree-DIHp6UQ0.js.map → tree-C-N2kP-8.js.map} +1 -1
- package/dist/{types-DsuOcYsE.d.ts → types-BsdcSWnf.d.ts} +2 -2
- package/dist/{types-DsuOcYsE.d.ts.map → types-BsdcSWnf.d.ts.map} +1 -1
- package/dist/{types-DNB9hIXa.d.ts → types-DUVhW5V1.d.ts} +3 -2
- package/dist/types-DUVhW5V1.d.ts.map +1 -0
- package/dist/{types-wDBk14lj.d.ts → types-ip2D3-Ib.d.ts} +5 -4
- package/dist/types-ip2D3-Ib.d.ts.map +1 -0
- package/dist/{types-B9s9Xo5_.d.ts → types-kBMNdo1X.d.ts} +3 -9
- package/dist/types-kBMNdo1X.d.ts.map +1 -0
- package/dist/wire/index.d.ts +4 -4
- package/dist/wire/index.js +1 -1
- package/docs/design/statistics-decisions.md +45 -364
- package/docs/design.md +1 -1
- package/docs/research-report-methodology.md +1 -1
- package/package.json +6 -1
- package/dist/agreement-irr-DXcXEt4I.js +0 -182
- package/dist/agreement-irr-DXcXEt4I.js.map +0 -1
- package/dist/analyze-runs-C7vWBDhl.js.map +0 -1
- package/dist/benchmark-command-DSJQeYom.js.map +0 -1
- package/dist/cluster-bootstrap-BteuR1hg.js +0 -65
- package/dist/cluster-bootstrap-BteuR1hg.js.map +0 -1
- package/dist/descriptive-B3Eb7tX0.js +0 -229
- package/dist/descriptive-B3Eb7tX0.js.map +0 -1
- package/dist/findings-store-BnYN57-h.js.map +0 -1
- package/dist/index-BPmj-_ta.d.ts.map +0 -1
- package/dist/index-C3t17kHu.d.ts.map +0 -1
- package/dist/index-D4lT7aFu.d.ts.map +0 -1
- package/dist/judge-calibration-DKR6Xi-w.js +0 -319
- package/dist/judge-calibration-DKR6Xi-w.js.map +0 -1
- package/dist/judge-calibration-DnrbQaXI.d.ts +0 -144
- package/dist/judge-calibration-DnrbQaXI.d.ts.map +0 -1
- package/dist/mean-D1d6gedE.js +0 -284
- package/dist/mean-D1d6gedE.js.map +0 -1
- package/dist/metrics-DNCAUtuB.js.map +0 -1
- package/dist/multiplicity-DAd4xaDC.js +0 -100
- package/dist/multiplicity-DAd4xaDC.js.map +0 -1
- package/dist/multiplicity-D_SEsc5j.d.ts +0 -41
- package/dist/multiplicity-D_SEsc5j.d.ts.map +0 -1
- package/dist/paired-arms-3-tsXvvC.js +0 -740
- package/dist/paired-arms-3-tsXvvC.js.map +0 -1
- package/dist/paired-binary-CMzmSSd5.js +0 -372
- package/dist/paired-binary-CMzmSSd5.js.map +0 -1
- package/dist/paired-promotion-decision-BDnqepZ1.d.ts.map +0 -1
- package/dist/paired-tests-Buh6feJ4.js +0 -211
- package/dist/paired-tests-Buh6feJ4.js.map +0 -1
- package/dist/power-and-mde-g3vOn0XK.js +0 -99
- package/dist/power-and-mde-g3vOn0XK.js.map +0 -1
- package/dist/promotion-gate-DOkgJcLW.d.ts.map +0 -1
- package/dist/random-BN150Q_X.d.ts +0 -79
- package/dist/random-BN150Q_X.d.ts.map +0 -1
- package/dist/schema-CfoA9U_U.d.ts.map +0 -1
- package/dist/sequential-eprocess-C1YLwFaz.js +0 -129
- package/dist/sequential-eprocess-C1YLwFaz.js.map +0 -1
- package/dist/statistical-heldout-C-tgpUuu.d.ts.map +0 -1
- package/dist/summary-report-C3IJvp0i.js.map +0 -1
- package/dist/tool-groups-BQsjZD9F.d.ts.map +0 -1
- package/dist/types-0KglnQ9o.d.ts.map +0 -1
- package/dist/types-B9s9Xo5_.d.ts.map +0 -1
- package/dist/types-DNB9hIXa.d.ts.map +0 -1
- package/dist/types-wDBk14lj.d.ts.map +0 -1
|
@@ -1,740 +0,0 @@
|
|
|
1
|
-
import { s as ValidationError } from "./errors-DeEEV9Vx.js";
|
|
2
|
-
import { a as findingTreatmentSchema } from "./finding-composition-Belh_qU3.js";
|
|
3
|
-
import { a as assertFiniteSample, d as symmetricTwoSampleSeed, h as lnGamma, l as makeRng, s as binomialSignTwoSided } from "./mean-D1d6gedE.js";
|
|
4
|
-
import { r as pairedRiskDifference, t as mcnemar } from "./paired-binary-CMzmSSd5.js";
|
|
5
|
-
import { r as pairedBootstrap } from "./paired-tests-Buh6feJ4.js";
|
|
6
|
-
// src/arm-populations.ts
|
|
7
|
-
const keyOf = (row) => JSON.stringify([
|
|
8
|
-
row.arm,
|
|
9
|
-
row.pairKey,
|
|
10
|
-
row.repKey ?? null
|
|
11
|
-
]);
|
|
12
|
-
function checkIdentity(row) {
|
|
13
|
-
for (const value of [
|
|
14
|
-
row.arm,
|
|
15
|
-
row.pairKey,
|
|
16
|
-
...row.repKey === void 0 ? [] : [row.repKey]
|
|
17
|
-
]) if (typeof value !== "string" || !value.trim()) throw new TypeError("Arm assignments require nonempty identities");
|
|
18
|
-
if (row.treatment !== void 0) {
|
|
19
|
-
if (!Array.isArray(row.treatment)) throw new TypeError("Arm treatment must be an array");
|
|
20
|
-
for (const value of row.treatment) findingTreatmentSchema.parse(value);
|
|
21
|
-
if (new Set(row.treatment.map((t) => t.id)).size !== row.treatment.length) throw new TypeError("Duplicate arm treatment id");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function checkObservation(row) {
|
|
25
|
-
checkIdentity(row);
|
|
26
|
-
if (row.pass != null && typeof row.pass !== "boolean") throw new TypeError("Invalid arm pass value");
|
|
27
|
-
if (row.formation !== void 0) {
|
|
28
|
-
if (row.formation === null || typeof row.formation !== "object") throw new TypeError("Invalid formation verdict");
|
|
29
|
-
if (row.formation.formed !== null && typeof row.formation.formed !== "boolean") throw new TypeError("Invalid formation state");
|
|
30
|
-
if (row.formation.reason !== void 0 && typeof row.formation.reason !== "string") throw new TypeError("Invalid formation reason");
|
|
31
|
-
}
|
|
32
|
-
for (const value of Object.values(row.metrics ?? {})) if (value !== null && !Number.isFinite(value)) throw new TypeError("Non-finite arm metric");
|
|
33
|
-
}
|
|
34
|
-
/** One roster join serves comparison and both denominators; no outcomes are inferred from formation. */
|
|
35
|
-
function prepareArmPopulations(observations, assignments, options) {
|
|
36
|
-
const arms = [options.baselineArm, options.treatmentArm];
|
|
37
|
-
const roster = /* @__PURE__ */ new Map();
|
|
38
|
-
for (const entry of assignments) {
|
|
39
|
-
if (!arms.includes(entry.arm)) continue;
|
|
40
|
-
checkIdentity(entry);
|
|
41
|
-
const key = keyOf(entry);
|
|
42
|
-
if (roster.has(key)) throw new TypeError("Duplicate arm assignment");
|
|
43
|
-
roster.set(key, structuredClone(entry));
|
|
44
|
-
}
|
|
45
|
-
for (const arm of arms) if (![...roster.values()].some((r) => r.arm === arm)) throw new TypeError(`No assignment roster for arm '${arm}'`);
|
|
46
|
-
const actual = /* @__PURE__ */ new Map();
|
|
47
|
-
for (const row of observations) {
|
|
48
|
-
if (!arms.includes(row.arm)) continue;
|
|
49
|
-
checkObservation(row);
|
|
50
|
-
const key = keyOf(row);
|
|
51
|
-
if (!roster.has(key)) throw new TypeError("Observed seed is outside the assignment roster");
|
|
52
|
-
if (actual.has(key)) throw new TypeError("Duplicate arm observation");
|
|
53
|
-
actual.set(key, row);
|
|
54
|
-
}
|
|
55
|
-
const ordered = [...roster.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
56
|
-
const rows = ordered.map(([key, entry]) => actual.get(key) ?? entry);
|
|
57
|
-
const metricNames = options.metricNames ?? [...new Set([...actual.values()].flatMap((r) => Object.keys(r.metrics ?? {})))].sort();
|
|
58
|
-
return {
|
|
59
|
-
rows,
|
|
60
|
-
readings: arms.map((arm) => {
|
|
61
|
-
const declared = ordered.filter(([, r]) => r.arm === arm);
|
|
62
|
-
const asAssigned = declared.map(([key]) => actual.get(key));
|
|
63
|
-
const asFormed = asAssigned.filter((row) => row?.formation?.formed === true);
|
|
64
|
-
return {
|
|
65
|
-
arm,
|
|
66
|
-
assignments: declared.map(([, r]) => r),
|
|
67
|
-
missingObservations: asAssigned.filter((r) => r === void 0).length,
|
|
68
|
-
formation: {
|
|
69
|
-
formed: asFormed.length,
|
|
70
|
-
notFormed: asAssigned.filter((r) => r?.formation?.formed === false).length,
|
|
71
|
-
unknown: asAssigned.filter((r) => r?.formation?.formed == null).length
|
|
72
|
-
},
|
|
73
|
-
asAssigned: summarize(asAssigned, metricNames),
|
|
74
|
-
asFormed: summarize(asFormed, metricNames)
|
|
75
|
-
};
|
|
76
|
-
})
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function summarize(rows, names) {
|
|
80
|
-
const passed = rows.filter((r) => r?.pass === true).length;
|
|
81
|
-
const failed = rows.filter((r) => r?.pass === false).length;
|
|
82
|
-
const missingOutcomes = rows.length - passed - failed;
|
|
83
|
-
const metrics = Object.fromEntries(names.map((name) => {
|
|
84
|
-
const values = rows.map((r) => r?.metrics?.[name]).filter((x) => x != null);
|
|
85
|
-
const sum = values.length ? values.reduce((s, v) => s + v, 0) : null;
|
|
86
|
-
return [name, {
|
|
87
|
-
n: values.length,
|
|
88
|
-
missing: rows.length - values.length,
|
|
89
|
-
sum,
|
|
90
|
-
mean: sum === null ? null : sum / values.length
|
|
91
|
-
}];
|
|
92
|
-
}));
|
|
93
|
-
return {
|
|
94
|
-
n: rows.length,
|
|
95
|
-
passed,
|
|
96
|
-
failed,
|
|
97
|
-
missingOutcomes,
|
|
98
|
-
passRate: rows.length && !missingOutcomes ? passed / rows.length : null,
|
|
99
|
-
metrics
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
// src/math/normal.ts
|
|
103
|
-
/**
|
|
104
|
-
* Standard normal cumulative distribution using Abramowitz and Stegun 7.1.26.
|
|
105
|
-
*
|
|
106
|
-
* The approximation is evaluated as erf(x / sqrt(2)). Computing the negative
|
|
107
|
-
* tail from the complementary term avoids cancellation when x is far below 0.
|
|
108
|
-
* The maximum absolute CDF error is approximately 7.5e-8.
|
|
109
|
-
*/
|
|
110
|
-
function normalCdf(x) {
|
|
111
|
-
if (x === 0) return .5;
|
|
112
|
-
const a1 = .254829592;
|
|
113
|
-
const a2 = -.284496736;
|
|
114
|
-
const a3 = 1.421413741;
|
|
115
|
-
const a4 = -1.453152027;
|
|
116
|
-
const a5 = 1.061405429;
|
|
117
|
-
const p = .3275911;
|
|
118
|
-
const scaled = Math.abs(x) / Math.SQRT2;
|
|
119
|
-
const t = 1 / (1 + p * scaled);
|
|
120
|
-
const complement = ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t * Math.exp(-scaled * scaled);
|
|
121
|
-
return x < 0 ? complement / 2 : 1 - complement / 2;
|
|
122
|
-
}
|
|
123
|
-
// src/statistics/rank-tests.ts
|
|
124
|
-
/** Maximum dynamic-programming cells used by an exact two-sample rank test. */
|
|
125
|
-
const MANN_WHITNEY_EXACT_MAX_STATES = 8192;
|
|
126
|
-
/** Maximum inner-loop transitions used by an exact two-sample rank test. */
|
|
127
|
-
const MANN_WHITNEY_EXACT_MAX_WORK = 25e4;
|
|
128
|
-
/** Non-zero differences up to which the signed-rank null is enumerated exactly. */
|
|
129
|
-
const WILCOXON_EXACT_MAX_N = 20;
|
|
130
|
-
/** Resamples used when a rank test falls back to Monte Carlo permutation. */
|
|
131
|
-
const DEFAULT_PERMUTATIONS = 1e5;
|
|
132
|
-
/**
|
|
133
|
-
* Mann-Whitney U — two independent samples, no distributional assumption.
|
|
134
|
-
*
|
|
135
|
-
* Exact conditional (permutation) p by default when the dynamic program fits
|
|
136
|
-
* {@link MANN_WHITNEY_EXACT_MAX_STATES} cells and
|
|
137
|
-
* {@link MANN_WHITNEY_EXACT_MAX_WORK} transitions, seeded Monte Carlo
|
|
138
|
-
* permutation above those limits. This keeps imbalanced designs such as 1+24
|
|
139
|
-
* exact without admitting expensive balanced designs merely because they have
|
|
140
|
-
* the same total size. Throws on non-finite input and on `method:
|
|
141
|
-
* 'asymptotic'` where an exact answer is available. Empty input yields `p = 1,
|
|
142
|
-
* pFloor = 1` — no design, no attainable evidence.
|
|
143
|
-
*/
|
|
144
|
-
function mannWhitneyU(a, b, opts = {}) {
|
|
145
|
-
assertFiniteSample("mannWhitneyU", "a", a);
|
|
146
|
-
assertFiniteSample("mannWhitneyU", "b", b);
|
|
147
|
-
const n1 = a.length;
|
|
148
|
-
const n2 = b.length;
|
|
149
|
-
if (n1 === 0 || n2 === 0) return {
|
|
150
|
-
u: 0,
|
|
151
|
-
uA: 0,
|
|
152
|
-
p: 1,
|
|
153
|
-
method: "exact",
|
|
154
|
-
pFloor: 1
|
|
155
|
-
};
|
|
156
|
-
const total = n1 + n2;
|
|
157
|
-
const combined = [...a.map((v) => ({
|
|
158
|
-
v,
|
|
159
|
-
fromA: true
|
|
160
|
-
})), ...b.map((v) => ({
|
|
161
|
-
v,
|
|
162
|
-
fromA: false
|
|
163
|
-
}))].sort((x, y) => x.v - y.v);
|
|
164
|
-
const { midranks, tieTerm } = midranksWithTieTerm(combined.map((entry) => entry.v));
|
|
165
|
-
let rankSumA = 0;
|
|
166
|
-
for (let k = 0; k < total; k++) if (combined[k].fromA) rankSumA += midranks[k];
|
|
167
|
-
const uA = rankSumA - n1 * (n1 + 1) / 2;
|
|
168
|
-
const u = Math.min(uA, n1 * n2 - uA);
|
|
169
|
-
const doubled = midranks.map((rank) => Math.round(rank * 2));
|
|
170
|
-
const doubledDeviation = Math.abs(2 * uA - n1 * n2);
|
|
171
|
-
const selectedN = Math.min(n1, n2);
|
|
172
|
-
const otherN = total - selectedN;
|
|
173
|
-
const exactCost = exactTwoSampleCost(doubled, selectedN);
|
|
174
|
-
const designFloor = exactTwoSampleFloor(doubled, selectedN);
|
|
175
|
-
const method = selectRankTestMethod("mannWhitneyU", opts.method ?? "auto", `n1=${n1}, n2=${n2}`, exactCost.states <= MANN_WHITNEY_EXACT_MAX_STATES && exactCost.work <= MANN_WHITNEY_EXACT_MAX_WORK, designFloor, `${MANN_WHITNEY_EXACT_MAX_STATES.toLocaleString("en-US")} states and ${MANN_WHITNEY_EXACT_MAX_WORK.toLocaleString("en-US")} transitions`);
|
|
176
|
-
if (method === "exact") {
|
|
177
|
-
const { p, pFloor } = exactTwoSampleP(doubled, selectedN, otherN, doubledDeviation);
|
|
178
|
-
return {
|
|
179
|
-
u,
|
|
180
|
-
uA,
|
|
181
|
-
p,
|
|
182
|
-
method,
|
|
183
|
-
pFloor
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
if (method === "asymptotic") return {
|
|
187
|
-
u,
|
|
188
|
-
uA,
|
|
189
|
-
p: asymptoticTwoSidedP(doubledDeviation / 2, twoSampleSigma(n1, n2, total, tieTerm)),
|
|
190
|
-
method,
|
|
191
|
-
pFloor: designFloor
|
|
192
|
-
};
|
|
193
|
-
const permutations = resolvePermutations("mannWhitneyU", opts.permutations);
|
|
194
|
-
const rng = opts.seed === void 0 ? makeRng(symmetricTwoSampleSeed(a, b)) : makeRng(opts.seed);
|
|
195
|
-
let atLeastAsExtreme = 0;
|
|
196
|
-
const pool = [...doubled];
|
|
197
|
-
for (let iteration = 0; iteration < permutations; iteration++) {
|
|
198
|
-
let doubledRankSum = 0;
|
|
199
|
-
for (let k = 0; k < selectedN; k++) {
|
|
200
|
-
const pick = k + Math.floor(rng() * (total - k));
|
|
201
|
-
const swapped = pool[pick];
|
|
202
|
-
pool[pick] = pool[k];
|
|
203
|
-
pool[k] = swapped;
|
|
204
|
-
doubledRankSum += swapped;
|
|
205
|
-
}
|
|
206
|
-
if (Math.abs(doubledRankSum - selectedN * (selectedN + 1) - selectedN * otherN) >= doubledDeviation) atLeastAsExtreme++;
|
|
207
|
-
}
|
|
208
|
-
const pFloor = Math.max(1 / (permutations + 1), designFloor);
|
|
209
|
-
return {
|
|
210
|
-
u,
|
|
211
|
-
uA,
|
|
212
|
-
p: Math.max((1 + atLeastAsExtreme) / (permutations + 1), pFloor),
|
|
213
|
-
method,
|
|
214
|
-
pFloor
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Wilcoxon signed-rank — paired, no distributional assumption on the deltas.
|
|
219
|
-
*
|
|
220
|
-
* Exact conditional (sign-flip) p by default at `n ≤
|
|
221
|
-
* {@link WILCOXON_EXACT_MAX_N}` non-zero differences, seeded Monte Carlo
|
|
222
|
-
* permutation above it. Throws on non-finite input and on `method:
|
|
223
|
-
* 'asymptotic'` where an exact answer is available.
|
|
224
|
-
*
|
|
225
|
-
* `n` is the count of NON-ZERO differences: exact ties are dropped before
|
|
226
|
-
* ranking, so a run of tied pairs shrinks the design and raises `pFloor`.
|
|
227
|
-
* All-tied input yields `p = 1, pFloor = 1` — no attainable evidence, which
|
|
228
|
-
* `pFloor` states rather than leaving `p = 1` to be read as a measured null.
|
|
229
|
-
*/
|
|
230
|
-
function wilcoxonSignedRank(before, after, opts = {}) {
|
|
231
|
-
if (before.length !== after.length) throw new ValidationError(`wilcoxonSignedRank: unequal sample sizes (${before.length} vs ${after.length})`);
|
|
232
|
-
assertFiniteSample("wilcoxonSignedRank", "before", before);
|
|
233
|
-
assertFiniteSample("wilcoxonSignedRank", "after", after);
|
|
234
|
-
const diffs = before.map((b, i) => after[i] - b).filter((d) => d !== 0);
|
|
235
|
-
const n = diffs.length;
|
|
236
|
-
if (n === 0) return {
|
|
237
|
-
w: 0,
|
|
238
|
-
p: 1,
|
|
239
|
-
method: "exact",
|
|
240
|
-
pFloor: 1,
|
|
241
|
-
nNonZero: 0
|
|
242
|
-
};
|
|
243
|
-
const abs = Math.abs(diffs[0]);
|
|
244
|
-
const allEqualAbs = diffs.every((d) => Math.abs(d) === abs);
|
|
245
|
-
if ((opts.method === void 0 || opts.method === "auto") && allEqualAbs) {
|
|
246
|
-
const positive = diffs.filter((d) => d > 0).length;
|
|
247
|
-
const negative = n - positive;
|
|
248
|
-
return {
|
|
249
|
-
w: positive * (n + 1) / 2,
|
|
250
|
-
p: binomialSignTwoSided(positive, negative),
|
|
251
|
-
method: "exact",
|
|
252
|
-
pFloor: Math.min(1, 2 ** (1 - n)),
|
|
253
|
-
nNonZero: n
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
const order = diffs.map((d, i) => ({
|
|
257
|
-
abs: Math.abs(d),
|
|
258
|
-
i
|
|
259
|
-
})).sort((x, y) => x.abs - y.abs);
|
|
260
|
-
const { midranks, tieTerm } = midranksWithTieTerm(order.map((entry) => entry.abs));
|
|
261
|
-
const ranks = new Array(n);
|
|
262
|
-
for (let k = 0; k < n; k++) ranks[order[k].i] = midranks[k];
|
|
263
|
-
let wPlus = 0;
|
|
264
|
-
for (let k = 0; k < n; k++) if (diffs[k] > 0) wPlus += ranks[k];
|
|
265
|
-
const doubled = midranks.map((rank) => Math.round(rank * 2));
|
|
266
|
-
const doubledDeviation = Math.abs(2 * wPlus - n * (n + 1) / 2);
|
|
267
|
-
const designFloor = Math.min(1, 2 ** (1 - n));
|
|
268
|
-
const method = selectRankTestMethod("wilcoxonSignedRank", opts.method ?? "auto", `n=${n} non-zero differences`, n <= WILCOXON_EXACT_MAX_N, designFloor, `${WILCOXON_EXACT_MAX_N} non-zero differences`);
|
|
269
|
-
if (method === "exact") {
|
|
270
|
-
const { p, pFloor } = exactSignedRankP(doubled, doubledDeviation);
|
|
271
|
-
return {
|
|
272
|
-
w: wPlus,
|
|
273
|
-
p,
|
|
274
|
-
method,
|
|
275
|
-
pFloor,
|
|
276
|
-
nNonZero: n
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
if (method === "asymptotic") {
|
|
280
|
-
const variance = n * (n + 1) * (2 * n + 1) / 24 - tieTerm / 48;
|
|
281
|
-
return {
|
|
282
|
-
w: wPlus,
|
|
283
|
-
p: asymptoticTwoSidedP(doubledDeviation / 2, Math.sqrt(variance)),
|
|
284
|
-
method,
|
|
285
|
-
pFloor: designFloor,
|
|
286
|
-
nNonZero: n
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
const permutations = resolvePermutations("wilcoxonSignedRank", opts.permutations);
|
|
290
|
-
const rng = makeRng(opts.seed, before, after);
|
|
291
|
-
const doubledCentre = n * (n + 1) / 2;
|
|
292
|
-
let atLeastAsExtreme = 0;
|
|
293
|
-
for (let iteration = 0; iteration < permutations; iteration++) {
|
|
294
|
-
let doubledWPlus = 0;
|
|
295
|
-
for (let k = 0; k < n; k++) if (rng() < .5) doubledWPlus += doubled[k];
|
|
296
|
-
if (Math.abs(doubledWPlus - doubledCentre) >= doubledDeviation) atLeastAsExtreme++;
|
|
297
|
-
}
|
|
298
|
-
return {
|
|
299
|
-
w: wPlus,
|
|
300
|
-
p: (1 + atLeastAsExtreme) / (permutations + 1),
|
|
301
|
-
method,
|
|
302
|
-
pFloor: Math.max(1 / (permutations + 1), designFloor),
|
|
303
|
-
nNonZero: n
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Average ranks over an ASCENDING-sorted array, plus `Σ(t³ − t)` over tie
|
|
308
|
-
* groups of size `t` — the correction term both asymptotic rank-test variances
|
|
309
|
-
* need.
|
|
310
|
-
*/
|
|
311
|
-
function midranksWithTieTerm(sorted) {
|
|
312
|
-
const midranks = new Array(sorted.length);
|
|
313
|
-
let tieTerm = 0;
|
|
314
|
-
let i = 0;
|
|
315
|
-
while (i < sorted.length) {
|
|
316
|
-
let j = i;
|
|
317
|
-
while (j < sorted.length && sorted[j] === sorted[i]) j++;
|
|
318
|
-
const average = (i + 1 + j) / 2;
|
|
319
|
-
for (let k = i; k < j; k++) midranks[k] = average;
|
|
320
|
-
const groupSize = j - i;
|
|
321
|
-
if (groupSize > 1) tieTerm += groupSize ** 3 - groupSize;
|
|
322
|
-
i = j;
|
|
323
|
-
}
|
|
324
|
-
return {
|
|
325
|
-
midranks,
|
|
326
|
-
tieTerm
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
function selectRankTestMethod(fn, request, design, exactFeasible, designFloor, threshold) {
|
|
330
|
-
if (request === "auto") return exactFeasible ? "exact" : "permutation";
|
|
331
|
-
if (request === "exact") {
|
|
332
|
-
if (exactFeasible) return "exact";
|
|
333
|
-
throw new ValidationError(`${fn}: method 'exact' is out of range at ${design} — enumeration is bounded by ${threshold}. Use 'auto' for the seeded Monte Carlo permutation, which converges to the same answer.`);
|
|
334
|
-
}
|
|
335
|
-
if (exactFeasible) throw new ValidationError(`${fn}: method 'asymptotic' is refused at ${design} — the exact p-grid at this design starts at ${formatProbability(designFloor)}, so an asymptotic p below it describes no attainable outcome. Use method 'exact' (the default) or add repetitions past ${threshold}.`);
|
|
336
|
-
return "asymptotic";
|
|
337
|
-
}
|
|
338
|
-
function resolvePermutations(fn, permutations) {
|
|
339
|
-
if (permutations === void 0) return DEFAULT_PERMUTATIONS;
|
|
340
|
-
if (!Number.isInteger(permutations) || permutations < 1) throw new ValidationError(`${fn}: permutations must be a positive integer, got ${permutations}`);
|
|
341
|
-
return permutations;
|
|
342
|
-
}
|
|
343
|
-
/** Two-sided normal-approximation tail with the continuity correction. */
|
|
344
|
-
function asymptoticTwoSidedP(deviation, sigma) {
|
|
345
|
-
if (!(sigma > 0)) return 1;
|
|
346
|
-
return Math.min(1, 2 * (1 - normalCdf(Math.max(0, deviation - .5) / sigma)));
|
|
347
|
-
}
|
|
348
|
-
/** SD of U under the permutation null, corrected for the realised ties. The
|
|
349
|
-
* tie term reduces (N+1) and reaches it exactly when every value is tied, so
|
|
350
|
-
* the variance floors at 0 rather than going negative. */
|
|
351
|
-
function twoSampleSigma(n1, n2, total, tieTerm) {
|
|
352
|
-
if (total < 2) return 0;
|
|
353
|
-
const variance = n1 * n2 / 12 * (total + 1 - tieTerm / (total * (total - 1)));
|
|
354
|
-
return Math.sqrt(Math.max(0, variance));
|
|
355
|
-
}
|
|
356
|
-
function logChoose(n, k) {
|
|
357
|
-
return lnGamma(n + 1) - lnGamma(k + 1) - lnGamma(n - k + 1);
|
|
358
|
-
}
|
|
359
|
-
function formatProbability(value) {
|
|
360
|
-
return value >= 1e-4 || value === 0 ? value.toFixed(4) : value.toExponential(3);
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Exact DP allocation and loop count for this observed rank vector.
|
|
364
|
-
*
|
|
365
|
-
* The smaller arm is sufficient because selecting its complement produces the
|
|
366
|
-
* same two-sided U deviation while using fewer rows in the state table.
|
|
367
|
-
*/
|
|
368
|
-
function exactTwoSampleCost(doubledRanks, selectedN) {
|
|
369
|
-
const maxSum = doubledRanks.reduce((sum, rank) => sum + rank, 0);
|
|
370
|
-
let work = 0;
|
|
371
|
-
for (let placed = 0; placed < doubledRanks.length; placed++) work += Math.min(selectedN, placed + 1) * (maxSum - doubledRanks[placed] + 1);
|
|
372
|
-
return {
|
|
373
|
-
states: (selectedN + 1) * (maxSum + 1),
|
|
374
|
-
work
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Smallest attainable two-sided p under the observed ties.
|
|
379
|
-
*
|
|
380
|
-
* Only subsets with the minimum or maximum rank sum can attain the largest
|
|
381
|
-
* deviation. Their multiplicity is the number of ways to choose within the
|
|
382
|
-
* tie group at each boundary, so this calculation is exact without allocating
|
|
383
|
-
* the full null distribution.
|
|
384
|
-
*/
|
|
385
|
-
function exactTwoSampleFloor(doubledRanks, selectedN) {
|
|
386
|
-
const total = doubledRanks.length;
|
|
387
|
-
const otherN = total - selectedN;
|
|
388
|
-
const minimumSum = doubledRanks.slice(0, selectedN).reduce((sum, rank) => sum + rank, 0);
|
|
389
|
-
const maximumSum = doubledRanks.slice(total - selectedN).reduce((sum, rank) => sum + rank, 0);
|
|
390
|
-
if (minimumSum === maximumSum) return 1;
|
|
391
|
-
const centre = selectedN * (selectedN + 1) + selectedN * otherN;
|
|
392
|
-
const minimumDeviation = Math.abs(minimumSum - centre);
|
|
393
|
-
const maximumDeviation = Math.abs(maximumSum - centre);
|
|
394
|
-
const totalLogWays = logChoose(total, selectedN);
|
|
395
|
-
const minimumMass = Math.exp(logExtremeSubsetWays(doubledRanks, selectedN, "minimum") - totalLogWays);
|
|
396
|
-
const maximumMass = Math.exp(logExtremeSubsetWays(doubledRanks, selectedN, "maximum") - totalLogWays);
|
|
397
|
-
if (minimumDeviation > maximumDeviation) return minimumMass;
|
|
398
|
-
if (maximumDeviation > minimumDeviation) return maximumMass;
|
|
399
|
-
return Math.min(1, minimumMass + maximumMass);
|
|
400
|
-
}
|
|
401
|
-
function logExtremeSubsetWays(sortedRanks, selectedN, side) {
|
|
402
|
-
const boundaryIndex = side === "minimum" ? selectedN - 1 : sortedRanks.length - selectedN;
|
|
403
|
-
const boundary = sortedRanks[boundaryIndex];
|
|
404
|
-
let first = boundaryIndex;
|
|
405
|
-
let afterLast = boundaryIndex + 1;
|
|
406
|
-
while (first > 0 && sortedRanks[first - 1] === boundary) first--;
|
|
407
|
-
while (afterLast < sortedRanks.length && sortedRanks[afterLast] === boundary) afterLast++;
|
|
408
|
-
return logChoose(afterLast - first, selectedN - (side === "minimum" ? first : sortedRanks.length - afterLast));
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Exact conditional two-sided p for the two-sample rank test.
|
|
412
|
-
*
|
|
413
|
-
* Convolves the observed doubled midranks into the null distribution of group
|
|
414
|
-
* a's rank sum over every `C(n₁+n₂, n₁)` split — identical to enumerating the
|
|
415
|
-
* splits, but `O(N·n₁·ΣR)` instead of `O(C(N,n₁)·n₁n₂)`. Conditioning on the
|
|
416
|
-
* realised multiset makes the tie handling exact rather than a correction.
|
|
417
|
-
*
|
|
418
|
-
* The null is symmetric about `n₁n₂/2` (negating every value maps `U → n₁n₂ −
|
|
419
|
-
* U` and permutes the split set onto itself), so the two-sided p is the mass
|
|
420
|
-
* at least as far from the centre as the observation.
|
|
421
|
-
*/
|
|
422
|
-
function exactTwoSampleP(doubledRanks, n1, n2, doubledDeviation) {
|
|
423
|
-
const maxSum = doubledRanks.reduce((sum, rank) => sum + rank, 0);
|
|
424
|
-
const width = maxSum + 1;
|
|
425
|
-
const ways = Array.from({ length: n1 + 1 }, () => new Float64Array(width));
|
|
426
|
-
ways[0][0] = 1;
|
|
427
|
-
let placed = 0;
|
|
428
|
-
for (const rank of doubledRanks) {
|
|
429
|
-
for (let k = Math.min(n1, placed + 1); k >= 1; k--) {
|
|
430
|
-
const from = ways[k - 1];
|
|
431
|
-
const into = ways[k];
|
|
432
|
-
for (let sum = maxSum - rank; sum >= 0; sum--) {
|
|
433
|
-
const count = from[sum];
|
|
434
|
-
if (count !== 0) into[sum + rank] += count;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
placed++;
|
|
438
|
-
}
|
|
439
|
-
const shift = n1 * (n1 + 1) + n1 * n2;
|
|
440
|
-
const chosen = ways[n1];
|
|
441
|
-
let totalWays = 0;
|
|
442
|
-
let extremeWays = 0;
|
|
443
|
-
let tailWays = 0;
|
|
444
|
-
let maxDeviation = -1;
|
|
445
|
-
for (let sum = 0; sum < width; sum++) {
|
|
446
|
-
const count = chosen[sum];
|
|
447
|
-
if (count === 0) continue;
|
|
448
|
-
totalWays += count;
|
|
449
|
-
const deviation = Math.abs(sum - shift);
|
|
450
|
-
if (deviation >= doubledDeviation) tailWays += count;
|
|
451
|
-
if (deviation > maxDeviation) {
|
|
452
|
-
maxDeviation = deviation;
|
|
453
|
-
extremeWays = count;
|
|
454
|
-
} else if (deviation === maxDeviation) extremeWays += count;
|
|
455
|
-
}
|
|
456
|
-
return {
|
|
457
|
-
p: tailWays / totalWays,
|
|
458
|
-
pFloor: extremeWays / totalWays
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Exact conditional two-sided p for the paired signed-rank test.
|
|
463
|
-
*
|
|
464
|
-
* Convolves the observed doubled absolute midranks over all `2ⁿ` sign
|
|
465
|
-
* assignments in `O(n·ΣR)`. Probabilities rather than counts keep `2ⁿ` off the
|
|
466
|
-
* arithmetic. The null is symmetric about `n(n+1)/4`.
|
|
467
|
-
*/
|
|
468
|
-
function exactSignedRankP(doubledRanks, doubledDeviation) {
|
|
469
|
-
const maxSum = doubledRanks.reduce((sum, rank) => sum + rank, 0);
|
|
470
|
-
const width = maxSum + 1;
|
|
471
|
-
let mass = new Float64Array(width);
|
|
472
|
-
mass[0] = 1;
|
|
473
|
-
for (const rank of doubledRanks) {
|
|
474
|
-
const next = new Float64Array(width);
|
|
475
|
-
for (let sum = 0; sum < width; sum++) {
|
|
476
|
-
const probability = mass[sum];
|
|
477
|
-
if (probability === 0) continue;
|
|
478
|
-
next[sum] += probability * .5;
|
|
479
|
-
next[sum + rank] += probability * .5;
|
|
480
|
-
}
|
|
481
|
-
mass = next;
|
|
482
|
-
}
|
|
483
|
-
const centre = maxSum / 2;
|
|
484
|
-
let tail = 0;
|
|
485
|
-
let extreme = 0;
|
|
486
|
-
let maxDeviation = -1;
|
|
487
|
-
for (let sum = 0; sum < width; sum++) {
|
|
488
|
-
const probability = mass[sum];
|
|
489
|
-
if (probability === 0) continue;
|
|
490
|
-
const deviation = Math.abs(sum - centre);
|
|
491
|
-
if (deviation >= doubledDeviation) tail += probability;
|
|
492
|
-
if (deviation > maxDeviation) {
|
|
493
|
-
maxDeviation = deviation;
|
|
494
|
-
extreme = probability;
|
|
495
|
-
} else if (deviation === maxDeviation) extreme += probability;
|
|
496
|
-
}
|
|
497
|
-
return {
|
|
498
|
-
p: Math.min(1, tail),
|
|
499
|
-
pFloor: Math.min(1, extreme)
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
// src/paired-arms.ts
|
|
503
|
-
/**
|
|
504
|
-
* Match rows across two arms into (baseline, treatment) pairs by `pairKey`.
|
|
505
|
-
*
|
|
506
|
-
* A `pairKey` with at most one row per arm pairs directly, no `repKey`
|
|
507
|
-
* needed. A `pairKey` with multiple reps in either arm requires `repKey` on
|
|
508
|
-
* every one of its rows, and reps pair only on exact (`pairKey`, `repKey`)
|
|
509
|
-
* match — pairing is keyed purely on row identity, never on outcome content
|
|
510
|
-
* (outcome-keyed matching deflates discordant counts and biases McNemar), and
|
|
511
|
-
* is therefore independent of input order. Reps whose `repKey` has no
|
|
512
|
-
* counterpart in the other arm, and items present in only one arm, land in
|
|
513
|
-
* the unpaired lists — reported, never truncated.
|
|
514
|
-
*
|
|
515
|
-
* Fail-loud: throws when either named arm has zero rows (an unknown arm
|
|
516
|
-
* name would otherwise read as "everything unpaired"), when the two arm
|
|
517
|
-
* names are equal, when a multi-rep `pairKey` has a row without `repKey`, or
|
|
518
|
-
* when a (`pairKey`, arm) group repeats a `repKey` (the match would be
|
|
519
|
-
* ambiguous).
|
|
520
|
-
*/
|
|
521
|
-
function pairArms(rows, opts) {
|
|
522
|
-
const { baselineArm, treatmentArm } = opts;
|
|
523
|
-
if (baselineArm === treatmentArm) throw new ValidationError(`pairArms: baselineArm and treatmentArm are both '${baselineArm}' — an arm cannot be compared to itself`);
|
|
524
|
-
const byArm = /* @__PURE__ */ new Map();
|
|
525
|
-
const armsSeen = /* @__PURE__ */ new Set();
|
|
526
|
-
for (const row of rows) {
|
|
527
|
-
armsSeen.add(row.arm);
|
|
528
|
-
if (row.arm !== baselineArm && row.arm !== treatmentArm) continue;
|
|
529
|
-
const byKey = byArm.get(row.arm) ?? /* @__PURE__ */ new Map();
|
|
530
|
-
const group = byKey.get(row.pairKey) ?? [];
|
|
531
|
-
group.push(row);
|
|
532
|
-
byKey.set(row.pairKey, group);
|
|
533
|
-
byArm.set(row.arm, byKey);
|
|
534
|
-
}
|
|
535
|
-
for (const arm of [baselineArm, treatmentArm]) if (!byArm.has(arm)) {
|
|
536
|
-
const seen = [...armsSeen].sort().join(", ") || "<none>";
|
|
537
|
-
throw new ValidationError(`pairArms: no rows for arm '${arm}' (arms present: ${seen})`);
|
|
538
|
-
}
|
|
539
|
-
const baselineByKey = byArm.get(baselineArm);
|
|
540
|
-
const treatmentByKey = byArm.get(treatmentArm);
|
|
541
|
-
const allKeys = [.../* @__PURE__ */ new Set([...baselineByKey.keys(), ...treatmentByKey.keys()])].sort();
|
|
542
|
-
const pairs = [];
|
|
543
|
-
const unpairedBaseline = [];
|
|
544
|
-
const unpairedTreatment = [];
|
|
545
|
-
for (const pairKey of allKeys) {
|
|
546
|
-
const b = baselineByKey.get(pairKey) ?? [];
|
|
547
|
-
const t = treatmentByKey.get(pairKey) ?? [];
|
|
548
|
-
if (b.length <= 1 && t.length <= 1) {
|
|
549
|
-
if (b.length === 1 && t.length === 1) {
|
|
550
|
-
const baseline = b[0];
|
|
551
|
-
const treatment = t[0];
|
|
552
|
-
if (baseline.repKey !== void 0 || treatment.repKey !== void 0) {
|
|
553
|
-
if (baseline.repKey === void 0 || treatment.repKey === void 0 || baseline.repKey !== treatment.repKey) {
|
|
554
|
-
unpairedBaseline.push(baseline);
|
|
555
|
-
unpairedTreatment.push(treatment);
|
|
556
|
-
continue;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
pairs.push({
|
|
560
|
-
pairKey,
|
|
561
|
-
repIndex: 0,
|
|
562
|
-
baseline,
|
|
563
|
-
treatment
|
|
564
|
-
});
|
|
565
|
-
} else {
|
|
566
|
-
unpairedBaseline.push(...b);
|
|
567
|
-
unpairedTreatment.push(...t);
|
|
568
|
-
}
|
|
569
|
-
continue;
|
|
570
|
-
}
|
|
571
|
-
const bByRep = indexByRepKey(b, pairKey, baselineArm);
|
|
572
|
-
const tByRep = indexByRepKey(t, pairKey, treatmentArm);
|
|
573
|
-
const repKeys = [.../* @__PURE__ */ new Set([...bByRep.keys(), ...tByRep.keys()])].sort();
|
|
574
|
-
let repIndex = 0;
|
|
575
|
-
for (const repKey of repKeys) {
|
|
576
|
-
const baseline = bByRep.get(repKey);
|
|
577
|
-
const treatment = tByRep.get(repKey);
|
|
578
|
-
if (baseline !== void 0 && treatment !== void 0) pairs.push({
|
|
579
|
-
pairKey,
|
|
580
|
-
repIndex: repIndex++,
|
|
581
|
-
baseline,
|
|
582
|
-
treatment
|
|
583
|
-
});
|
|
584
|
-
else if (baseline !== void 0) unpairedBaseline.push(baseline);
|
|
585
|
-
else if (treatment !== void 0) unpairedTreatment.push(treatment);
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
return {
|
|
589
|
-
pairs,
|
|
590
|
-
unpairedBaseline,
|
|
591
|
-
unpairedTreatment
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
/** Index a multi-rep (pairKey, arm) group by `repKey`, enforcing that every
|
|
595
|
-
* row carries one and that no repKey repeats within the group. */
|
|
596
|
-
function indexByRepKey(group, pairKey, arm) {
|
|
597
|
-
const byRep = /* @__PURE__ */ new Map();
|
|
598
|
-
for (const row of group) {
|
|
599
|
-
if (row.repKey === void 0) throw new ValidationError(`pairArms: pairKey '${pairKey}' has multiple reps in an arm, but a row in arm '${arm}' is missing repKey — multi-rep items require an explicit repKey on every row so reps pair by identity (pairing reps by outcome or by index would bias the paired statistics)`);
|
|
600
|
-
if (byRep.has(row.repKey)) throw new ValidationError(`pairArms: duplicate repKey '${row.repKey}' for pairKey '${pairKey}' in arm '${arm}' — (pairKey, repKey) must uniquely identify a rep within an arm`);
|
|
601
|
-
byRep.set(row.repKey, row);
|
|
602
|
-
}
|
|
603
|
-
return byRep;
|
|
604
|
-
}
|
|
605
|
-
/**
|
|
606
|
-
* Full matched-pair arm comparison: pair via {@link pairArms}, then compose
|
|
607
|
-
* the paired estimators from `statistics` over the matched pairs.
|
|
608
|
-
*
|
|
609
|
-
* Correctness uses only the pairs where both sides carry `pass` (`mcnemar.n`
|
|
610
|
-
* is that subset's size); each metric uses only the pairs where both sides
|
|
611
|
-
* carry a finite value for it, with the remainder counted in `nMissing`.
|
|
612
|
-
* Deltas are treatment − baseline throughout. With an assignment roster, pairing
|
|
613
|
-
* covers declared seed identities; missing observations remain identity-only rows
|
|
614
|
-
* and never contribute fabricated outcomes or metrics. Per-arm summaries report
|
|
615
|
-
* every assignment and the explicitly formed subset separately.
|
|
616
|
-
*
|
|
617
|
-
* Fail-loud: inherits {@link pairArms}'s unknown-arm throw, and throws on a
|
|
618
|
-
* non-finite metric value — silently treating corrupt telemetry as "metric
|
|
619
|
-
* absent" would misreport it as missing coverage.
|
|
620
|
-
*/
|
|
621
|
-
function comparePairedArms(rows, opts) {
|
|
622
|
-
const populations = opts.assignments === void 0 ? void 0 : prepareArmPopulations(rows, opts.assignments, opts);
|
|
623
|
-
const { pairs, unpairedBaseline, unpairedTreatment } = pairArms(populations?.rows ?? rows, opts);
|
|
624
|
-
let correctness = null;
|
|
625
|
-
const baselinePass = [];
|
|
626
|
-
const treatmentPass = [];
|
|
627
|
-
for (const pair of pairs) {
|
|
628
|
-
if (pair.baseline.pass == null || pair.treatment.pass == null) continue;
|
|
629
|
-
baselinePass.push(pair.baseline.pass ? 1 : 0);
|
|
630
|
-
treatmentPass.push(pair.treatment.pass ? 1 : 0);
|
|
631
|
-
}
|
|
632
|
-
if (baselinePass.length > 0) {
|
|
633
|
-
const mc = mcnemar(baselinePass, treatmentPass);
|
|
634
|
-
correctness = {
|
|
635
|
-
b10: mc.b,
|
|
636
|
-
b01: mc.c,
|
|
637
|
-
mcnemar: mc,
|
|
638
|
-
riskDifference: pairedRiskDifference(baselinePass, treatmentPass)
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
const metricDeltas = (opts.metricNames ?? [...new Set(pairs.flatMap((p) => [...Object.keys(p.baseline.metrics ?? {}), ...Object.keys(p.treatment.metrics ?? {})]))].sort()).map((name) => {
|
|
642
|
-
const before = [];
|
|
643
|
-
const after = [];
|
|
644
|
-
let nMissing = 0;
|
|
645
|
-
for (const pair of pairs) {
|
|
646
|
-
const b = metricValue(pair.baseline, name);
|
|
647
|
-
const t = metricValue(pair.treatment, name);
|
|
648
|
-
if (b === void 0 || t === void 0) {
|
|
649
|
-
nMissing++;
|
|
650
|
-
continue;
|
|
651
|
-
}
|
|
652
|
-
before.push(b);
|
|
653
|
-
after.push(t);
|
|
654
|
-
}
|
|
655
|
-
const bootstrapCi = before.length === 0 ? null : pairedBootstrap(before, after, opts.bootstrap);
|
|
656
|
-
return {
|
|
657
|
-
name,
|
|
658
|
-
n: before.length,
|
|
659
|
-
nMissing,
|
|
660
|
-
medianDelta: bootstrapCi?.median ?? null,
|
|
661
|
-
meanDelta: bootstrapCi?.mean ?? null,
|
|
662
|
-
bootstrapCi,
|
|
663
|
-
wilcoxon: before.length === 0 ? null : wilcoxonSignedRank(before, after)
|
|
664
|
-
};
|
|
665
|
-
});
|
|
666
|
-
return {
|
|
667
|
-
...populations ? { armPopulations: populations.readings } : {},
|
|
668
|
-
nPairs: pairs.length,
|
|
669
|
-
nUnpairedBaseline: unpairedBaseline.length,
|
|
670
|
-
nUnpairedTreatment: unpairedTreatment.length,
|
|
671
|
-
correctness,
|
|
672
|
-
metricDeltas
|
|
673
|
-
};
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Pair two RunRecord arms by the identity of the evaluated work:
|
|
677
|
-
* `(experimentId, scenarioId, seed)`.
|
|
678
|
-
*
|
|
679
|
-
* Falling back to array order, candidate id, or experiment id can compare
|
|
680
|
-
* different tasks and fabricate lift. Duplicate identities throw.
|
|
681
|
-
*/
|
|
682
|
-
function pairRunRecords(baselineRuns, treatmentRuns) {
|
|
683
|
-
const baselineRows = runRecordArmRows(baselineRuns, "baseline");
|
|
684
|
-
const treatmentRows = runRecordArmRows(treatmentRuns, "treatment");
|
|
685
|
-
validateRunRecordArmRows(baselineRows, "baseline");
|
|
686
|
-
validateRunRecordArmRows(treatmentRows, "treatment");
|
|
687
|
-
if (baselineRows.length === 0 || treatmentRows.length === 0) return {
|
|
688
|
-
pairs: [],
|
|
689
|
-
unpairedBaseline: baselineRows.map((row) => row.run),
|
|
690
|
-
unpairedTreatment: treatmentRows.map((row) => row.run)
|
|
691
|
-
};
|
|
692
|
-
const result = pairArms([...baselineRows, ...treatmentRows], {
|
|
693
|
-
baselineArm: "baseline",
|
|
694
|
-
treatmentArm: "treatment"
|
|
695
|
-
});
|
|
696
|
-
return {
|
|
697
|
-
pairs: result.pairs.map((pair) => {
|
|
698
|
-
const baseline = pair.baseline;
|
|
699
|
-
const treatment = pair.treatment;
|
|
700
|
-
return {
|
|
701
|
-
pairKey: pair.pairKey,
|
|
702
|
-
repKey: baseline.repKey,
|
|
703
|
-
baseline: baseline.run,
|
|
704
|
-
treatment: treatment.run
|
|
705
|
-
};
|
|
706
|
-
}),
|
|
707
|
-
unpairedBaseline: result.unpairedBaseline.map((row) => row.run),
|
|
708
|
-
unpairedTreatment: result.unpairedTreatment.map((row) => row.run)
|
|
709
|
-
};
|
|
710
|
-
}
|
|
711
|
-
function runRecordArmRows(runs, arm) {
|
|
712
|
-
return runs.map((run) => {
|
|
713
|
-
const scenarioId = run.scenarioId.trim();
|
|
714
|
-
if (!scenarioId) throw new ValidationError(`pairRunRecords: run '${run.runId}' is missing scenarioId; paired comparisons require explicit scenario identity`);
|
|
715
|
-
return {
|
|
716
|
-
pairKey: JSON.stringify([run.experimentId, scenarioId]),
|
|
717
|
-
repKey: String(run.seed),
|
|
718
|
-
arm,
|
|
719
|
-
run
|
|
720
|
-
};
|
|
721
|
-
});
|
|
722
|
-
}
|
|
723
|
-
function validateRunRecordArmRows(rows, arm) {
|
|
724
|
-
const byPairKey = /* @__PURE__ */ new Map();
|
|
725
|
-
for (const row of rows) {
|
|
726
|
-
const group = byPairKey.get(row.pairKey) ?? [];
|
|
727
|
-
group.push(row);
|
|
728
|
-
byPairKey.set(row.pairKey, group);
|
|
729
|
-
}
|
|
730
|
-
for (const [pairKey, group] of byPairKey) if (group.length > 1) indexByRepKey(group, pairKey, arm);
|
|
731
|
-
}
|
|
732
|
-
function metricValue(row, name) {
|
|
733
|
-
const v = row.metrics?.[name];
|
|
734
|
-
if (v == null) return void 0;
|
|
735
|
-
if (!Number.isFinite(v)) throw new ValidationError(`comparePairedArms: non-finite value for metric '${name}' on pairKey '${row.pairKey}' (arm '${row.arm}'): ${v}`);
|
|
736
|
-
return v;
|
|
737
|
-
}
|
|
738
|
-
export { wilcoxonSignedRank as a, mannWhitneyU as i, pairArms as n, normalCdf as o, pairRunRecords as r, comparePairedArms as t };
|
|
739
|
-
|
|
740
|
-
//# sourceMappingURL=paired-arms-3-tsXvvC.js.map
|