@tangle-network/agent-eval 2.0.7 → 2.0.10
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 +80 -16
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-CRdalpZv.d.ts → agent-profile-_JzxgLDM.d.ts} +11 -5
- package/dist/{agent-profile-CRdalpZv.d.ts.map → agent-profile-_JzxgLDM.d.ts.map} +1 -1
- package/dist/analyst/index.d.ts +14 -13
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +34 -13
- package/dist/analyst/index.js.map +1 -1
- package/dist/analyze-runs-Izz_ZeWg.d.ts +65 -0
- package/dist/analyze-runs-Izz_ZeWg.d.ts.map +1 -0
- package/dist/{analyze-runs-C_9cXPZn.js → analyze-runs-xhH2Qxoc.js} +6 -5
- package/dist/{analyze-runs-C_9cXPZn.js.map → analyze-runs-xhH2Qxoc.js.map} +1 -1
- package/dist/app-grade/index.d.ts +4 -4
- package/dist/app-grade/index.js +1 -1
- package/dist/{benchmark-command-DkBMUDwy.js → benchmark-command-CGQXNFj7.js} +12 -8
- package/dist/benchmark-command-CGQXNFj7.js.map +1 -0
- package/dist/benchmarks/index.d.ts +4 -4
- package/dist/benchmarks/index.js +4 -4
- package/dist/builder-eval/index.js +2 -2
- package/dist/calibration-CrORXMWx.d.ts +128 -0
- package/dist/calibration-CrORXMWx.d.ts.map +1 -0
- package/dist/{calibration-Cfoup0xz.js → calibration-Dz8mQb5P.js} +2 -2
- package/dist/{calibration-Cfoup0xz.js.map → calibration-Dz8mQb5P.js.map} +1 -1
- package/dist/campaign/index.d.ts +8 -8
- package/dist/campaign/index.js +13 -12
- package/dist/{campaign-DfSWSreo.js → campaign-eus7YRs2.js} +1590 -15
- package/dist/campaign-eus7YRs2.js.map +1 -0
- package/dist/{campaign-evidence-BojANgU7.d.ts → campaign-evidence-BOcX4w0r.d.ts} +5 -5
- package/dist/{campaign-evidence-BojANgU7.d.ts.map → campaign-evidence-BOcX4w0r.d.ts.map} +1 -1
- package/dist/{campaign-evidence-D_oBFfLc.js → campaign-evidence-KM5GTsHG.js} +5 -5
- package/dist/{campaign-evidence-D_oBFfLc.js.map → campaign-evidence-KM5GTsHG.js.map} +1 -1
- package/dist/{cluster-Bj90LK-1.d.ts → chat-client-BlTooBDA.d.ts} +9 -241
- package/dist/chat-client-BlTooBDA.d.ts.map +1 -0
- package/dist/{chat-client-CvyDOQBv.js → chat-client-Oyot5tyo.js} +2 -2
- package/dist/{chat-client-CvyDOQBv.js.map → chat-client-Oyot5tyo.js.map} +1 -1
- package/dist/{chat-json-call-DMrwmB-k.js → chat-json-call-DTmv2uNY.js} +2 -2
- package/dist/{chat-json-call-DMrwmB-k.js.map → chat-json-call-DTmv2uNY.js.map} +1 -1
- package/dist/cli.js +7 -7
- package/dist/cluster-BJ0nW3P7.d.ts +241 -0
- package/dist/cluster-BJ0nW3P7.d.ts.map +1 -0
- package/dist/{cluster-bootstrap-DPzVy3_K.js → cluster-bootstrap-CTC8Dd30.js} +3 -2
- package/dist/{cluster-bootstrap-DPzVy3_K.js.map → cluster-bootstrap-CTC8Dd30.js.map} +1 -1
- package/dist/{completion-verifier-DsotH2l3.js → completion-verifier-CCPG2Yc0.js} +3 -3
- package/dist/{completion-verifier-DsotH2l3.js.map → completion-verifier-CCPG2Yc0.js.map} +1 -1
- package/dist/{completion-verifier-Cy38EpGE.d.ts → completion-verifier-CQOC3_bm.d.ts} +2 -2
- package/dist/{completion-verifier-Cy38EpGE.d.ts.map → completion-verifier-CQOC3_bm.d.ts.map} +1 -1
- package/dist/contract/index.d.ts +14 -12
- package/dist/contract/index.js +14 -12
- package/dist/contract/index.js.map +1 -1
- package/dist/{decision-point-C46p-p9v.js → decision-point-CfqtnGop.js} +3 -3
- package/dist/{decision-point-C46p-p9v.js.map → decision-point-CfqtnGop.js.map} +1 -1
- package/dist/{default-registry-BWFPtmuI.js → default-registry-Rs5uzlfJ.js} +4 -4
- package/dist/{default-registry-BWFPtmuI.js.map → default-registry-Rs5uzlfJ.js.map} +1 -1
- package/dist/{default-registry-xoX0PMCb.d.ts → default-registry-X8McMoUV.d.ts} +6 -6
- package/dist/{default-registry-xoX0PMCb.d.ts.map → default-registry-X8McMoUV.d.ts.map} +1 -1
- package/dist/define-agent-eval-D8ntOXqV.js +96 -0
- package/dist/define-agent-eval-D8ntOXqV.js.map +1 -0
- package/dist/define-agent-eval-DH5-xi-F.d.ts +52 -0
- package/dist/define-agent-eval-DH5-xi-F.d.ts.map +1 -0
- package/dist/diagnosis/index.d.ts +3 -3
- package/dist/diagnosis/index.js +1 -1
- package/dist/{dspy-rlm-engine-r7YpKLhS.js → dspy-rlm-engine-ChE1PUM5.js} +3 -3
- package/dist/{dspy-rlm-engine-r7YpKLhS.js.map → dspy-rlm-engine-ChE1PUM5.js.map} +1 -1
- package/dist/{emitter-BjW3NnX-.js → emitter-xN9wGTVw.js} +9 -2
- package/dist/{emitter-BjW3NnX-.js.map → emitter-xN9wGTVw.js.map} +1 -1
- package/dist/{eval-campaign-Cyk-tkLh.js → eval-campaign-BciGnrGy.js} +3 -3
- package/dist/{eval-campaign-Cyk-tkLh.js.map → eval-campaign-BciGnrGy.js.map} +1 -1
- package/dist/{evaluation-X5E22NQK.d.ts → evaluation-CjZH6gW0.d.ts} +4 -4
- package/dist/{evaluation-X5E22NQK.d.ts.map → evaluation-CjZH6gW0.d.ts.map} +1 -1
- package/dist/evaluation.d.ts +1 -1
- package/dist/{exact-types-DjuabhUV.d.ts → exact-types-BIHqYBYf.d.ts} +2 -2
- package/dist/{exact-types-DjuabhUV.d.ts.map → exact-types-BIHqYBYf.d.ts.map} +1 -1
- package/dist/{execution-insight-CE20Bxq0.d.ts → execution-insight-YihQrSqd.d.ts} +2 -2
- package/dist/{execution-insight-CE20Bxq0.d.ts.map → execution-insight-YihQrSqd.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +5 -5
- package/dist/experiment/index.js +10 -184
- package/dist/experiment/index.js.map +1 -1
- package/dist/{external-optimizer-contracts-ZDBfbZ_s.js → external-optimizer-contracts-BFV8lnhl.js} +7 -2
- package/dist/{external-optimizer-contracts-ZDBfbZ_s.js.map → external-optimizer-contracts-BFV8lnhl.js.map} +1 -1
- package/dist/{external-optimizer-process-4QdcF7Kd.js → external-optimizer-process-B6emPodQ.js} +3 -3
- package/dist/{external-optimizer-process-4QdcF7Kd.js.map → external-optimizer-process-B6emPodQ.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-BW0ZWUUr.js → external-optimizer-subprocess-_O06eDVA.js} +35 -376
- package/dist/external-optimizer-subprocess-_O06eDVA.js.map +1 -0
- package/dist/{feedback-trajectory-BMkJezPc.d.ts → feedback-trajectory-CoQPmSJV.d.ts} +3 -3
- package/dist/{feedback-trajectory-BMkJezPc.d.ts.map → feedback-trajectory-CoQPmSJV.d.ts.map} +1 -1
- package/dist/finding-scope-B_As3F_v.js +359 -0
- package/dist/finding-scope-B_As3F_v.js.map +1 -0
- package/dist/{findings-store-DV8WA5nD.js → findings-store-CvYUzQBR.js} +4 -4
- package/dist/{findings-store-DV8WA5nD.js.map → findings-store-CvYUzQBR.js.map} +1 -1
- package/dist/fuzz.js +1 -1
- package/dist/{index-C6TG1LwA.d.ts → index-BSb3fJyZ.d.ts} +318 -131
- package/dist/index-BSb3fJyZ.d.ts.map +1 -0
- package/dist/{index-CKjqN9_U.d.ts → index-Bk1XEkP7.d.ts} +99 -3
- package/dist/index-Bk1XEkP7.d.ts.map +1 -0
- package/dist/{index-DAFZRMlF.d.ts → index-BmWw8zN6.d.ts} +10 -8
- package/dist/index-BmWw8zN6.d.ts.map +1 -0
- package/dist/{index-DKpMyD_Z.d.ts → index-CCOaNmh2.d.ts} +7 -7
- package/dist/{index-DKpMyD_Z.d.ts.map → index-CCOaNmh2.d.ts.map} +1 -1
- package/dist/{index-xEM_SoCl.d.ts → index-ZffK_5sD.d.ts} +22 -20
- package/dist/index-ZffK_5sD.d.ts.map +1 -0
- package/dist/{index-BqAPIToS.d.ts → index-aRalB_Ma.d.ts} +3 -3
- package/dist/{index-BqAPIToS.d.ts.map → index-aRalB_Ma.d.ts.map} +1 -1
- package/dist/index.d.ts +33 -29
- package/dist/index.js +28 -25
- package/dist/index.js.map +1 -1
- package/dist/{analyze-runs-xjKBBqIB.d.ts → insight-report-DYofCMLx.d.ts} +4 -64
- package/dist/insight-report-DYofCMLx.d.ts.map +1 -0
- package/dist/{integrity-BF0tJK21.js → integrity-DacT3oJ1.js} +2 -2
- package/dist/{integrity-BF0tJK21.js.map → integrity-DacT3oJ1.js.map} +1 -1
- package/dist/{integrity-B9320cw1.d.ts → integrity-DotDLWtj.d.ts} +2 -2
- package/dist/{integrity-B9320cw1.d.ts.map → integrity-DotDLWtj.d.ts.map} +1 -1
- package/dist/{judge-gate-DqlzOBOm.js → judge-gate-CpD3wmcf.js} +3 -3
- package/dist/{judge-gate-DqlzOBOm.js.map → judge-gate-CpD3wmcf.js.map} +1 -1
- package/dist/{llm-client-Dw4x6EdE.js → llm-client-Dk8lBnMh.js} +15 -2
- package/dist/{llm-client-Dw4x6EdE.js.map → llm-client-Dk8lBnMh.js.map} +1 -1
- package/dist/llm-judge-DYmEdo3M.js +476 -0
- package/dist/llm-judge-DYmEdo3M.js.map +1 -0
- package/dist/{matrix-CqZSpwgN.d.ts → matrix-BDl7hoBr.d.ts} +6 -2
- package/dist/matrix-BDl7hoBr.d.ts.map +1 -0
- package/dist/measure-validity-plan-BReXzcVh.d.ts +201 -0
- package/dist/measure-validity-plan-BReXzcVh.d.ts.map +1 -0
- package/dist/measure-validity-plan-CJkBNzX_.js +154 -0
- package/dist/measure-validity-plan-CJkBNzX_.js.map +1 -0
- package/dist/meta-eval/index.d.ts +5 -3
- package/dist/meta-eval/index.js +808 -15
- package/dist/meta-eval/index.js.map +1 -1
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +497 -4
- package/dist/multishot/index.d.ts.map +1 -1
- package/dist/multishot/index.js +1000 -48
- package/dist/multishot/index.js.map +1 -1
- package/dist/node-transport-DJno8V46.js +62 -0
- package/dist/node-transport-DJno8V46.js.map +1 -0
- package/dist/openapi.json +1 -1
- package/dist/{llm-judge-DQJTQx01.js → optimization-method-4JlbMxd2.js} +38 -513
- package/dist/optimization-method-4JlbMxd2.js.map +1 -0
- package/dist/{outcome-observations-DL3CC8w1.js → outcome-observations-DEh8_V_P.js} +31 -6
- package/dist/outcome-observations-DEh8_V_P.js.map +1 -0
- package/dist/outcome-store-CHtuvstd.d.ts +56 -0
- package/dist/outcome-store-CHtuvstd.d.ts.map +1 -0
- package/dist/{paired-arms-DZhH3FGu.js → paired-arms-CJH5Q0wx.js} +3 -2
- package/dist/{paired-arms-DZhH3FGu.js.map → paired-arms-CJH5Q0wx.js.map} +1 -1
- package/dist/{paired-promotion-decision-Dn3-jaq4.js → paired-promotion-decision-BtfVwEAk.js} +3 -2
- package/dist/{paired-promotion-decision-Dn3-jaq4.js.map → paired-promotion-decision-BtfVwEAk.js.map} +1 -1
- package/dist/{paired-promotion-decision-ChHBuuHV.d.ts → paired-promotion-decision-DJlI4z_k.d.ts} +2 -2
- package/dist/{paired-promotion-decision-ChHBuuHV.d.ts.map → paired-promotion-decision-DJlI4z_k.d.ts.map} +1 -1
- package/dist/{paired-promotion-power-BlzXdgMD.js → paired-promotion-power-DG1avBKf.js} +3 -3
- package/dist/{paired-promotion-power-BlzXdgMD.js.map → paired-promotion-power-DG1avBKf.js.map} +1 -1
- package/dist/paired-tests-CXcD_B80.js +688 -0
- package/dist/paired-tests-CXcD_B80.js.map +1 -0
- package/dist/pareto-DIVE5D0T.js +81 -0
- package/dist/pareto-DIVE5D0T.js.map +1 -0
- package/dist/pipelines/index.d.ts +2 -1
- package/dist/pipelines/index.d.ts.map +1 -1
- package/dist/pipelines/index.js +1 -1
- package/dist/{sequential-BphITa5b.js → power-COie_o6E.js} +181 -4
- package/dist/power-COie_o6E.js.map +1 -0
- package/dist/{prime-protocol-Cv6_47rh.d.ts → prime-protocol-BRMk6dGI.d.ts} +2 -2
- package/dist/{prime-protocol-Cv6_47rh.d.ts.map → prime-protocol-BRMk6dGI.d.ts.map} +1 -1
- package/dist/{promotion-gate-CGkxh36r.d.ts → promotion-gate-B0VTBoXg.d.ts} +2 -2
- package/dist/{promotion-gate-CGkxh36r.d.ts.map → promotion-gate-B0VTBoXg.d.ts.map} +1 -1
- package/dist/{promotion-policy-CxDIh-9p.js → promotion-policy-BgI7PsQn.js} +4 -4
- package/dist/{promotion-policy-CxDIh-9p.js.map → promotion-policy-BgI7PsQn.js.map} +1 -1
- package/dist/{proposal-findings-DedMih-u.js → proposal-findings-CfRFCFXS.js} +2 -2
- package/dist/{proposal-findings-DedMih-u.js.map → proposal-findings-CfRFCFXS.js.map} +1 -1
- package/dist/{registry-CIjC6SdV.d.ts → registry-BeInzotS.d.ts} +4 -4
- package/dist/{registry-CIjC6SdV.d.ts.map → registry-BeInzotS.d.ts.map} +1 -1
- package/dist/{release-confidence-BLHOMK5Q.js → release-confidence-Cndq1hwi.js} +2 -2
- package/dist/{release-confidence-BLHOMK5Q.js.map → release-confidence-Cndq1hwi.js.map} +1 -1
- package/dist/reporting.d.ts +5 -5
- package/dist/reporting.js +6 -5
- package/dist/reporting.js.map +1 -1
- package/dist/{research-report-D6XIK0eK.d.ts → research-report-CL5_UqCX.d.ts} +2 -2
- package/dist/{research-report-D6XIK0eK.d.ts.map → research-report-CL5_UqCX.d.ts.map} +1 -1
- package/dist/{researcher---DhHG4J.d.ts → researcher-BOpZP_Ja.d.ts} +4 -4
- package/dist/{researcher---DhHG4J.d.ts.map → researcher-BOpZP_Ja.d.ts.map} +1 -1
- package/dist/{reward-hacking-DKAflk2c.js → reward-hacking-DMTm1OBd.js} +2 -2
- package/dist/{reward-hacking-DKAflk2c.js.map → reward-hacking-DMTm1OBd.js.map} +1 -1
- package/dist/rl.d.ts +9 -8
- package/dist/rl.d.ts.map +1 -1
- package/dist/rl.js +11 -10
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +2 -2
- package/dist/rollout/index.js +1 -1
- package/dist/{rollout-B_lrpd9a.js → rollout--rSr43Pd.js} +2 -2
- package/dist/{rollout-B_lrpd9a.js.map → rollout--rSr43Pd.js.map} +1 -1
- package/dist/{rollout-nodes-Vas6OSxX.js → rollout-nodes-DFxKpIr2.js} +39 -10
- package/dist/rollout-nodes-DFxKpIr2.js.map +1 -0
- package/dist/{rubric-predictive-validity--6z0q8s6.js → rubric-predictive-validity-BXJ92Jp_.js} +3 -9
- package/dist/rubric-predictive-validity-BXJ92Jp_.js.map +1 -0
- package/dist/{rubric-predictive-validity-C9wc7f_D.d.ts → rubric-predictive-validity-DH94_0Q1.d.ts} +3 -56
- package/dist/rubric-predictive-validity-DH94_0Q1.d.ts.map +1 -0
- package/dist/{run-improvement-loop-BfwOUudy.d.ts → run-improvement-loop-BeHu5D9Z.d.ts} +396 -11
- package/dist/run-improvement-loop-BeHu5D9Z.d.ts.map +1 -0
- package/dist/{run-record-Bqg0NZ_e.js → run-record-CuO8ErrI.js} +3 -2
- package/dist/run-record-CuO8ErrI.js.map +1 -0
- package/dist/{runtime-rollouts-drQynu3t.js → runtime-rollouts-CE0MbQPq.js} +55 -8
- package/dist/runtime-rollouts-CE0MbQPq.js.map +1 -0
- package/dist/search/index.d.ts +2 -2
- package/dist/search/index.js +2 -2
- package/dist/{search-kernel-DJq9bUDU.d.ts → search-kernel-CJZ-ZSV1.d.ts} +3 -3
- package/dist/{search-kernel-DJq9bUDU.d.ts.map → search-kernel-CJZ-ZSV1.d.ts.map} +1 -1
- package/dist/{pareto-Bg75Gajo.js → search-kernel-mZc79S6N.js} +6 -88
- package/dist/search-kernel-mZc79S6N.js.map +1 -0
- package/dist/{search-summary-B1x1Vmzh.js → search-summary-CCgP2qXz.js} +4 -4
- package/dist/{search-summary-B1x1Vmzh.js.map → search-summary-CCgP2qXz.js.map} +1 -1
- package/dist/{define-agent-eval-Cjc0wWnO.d.ts → self-improve-B1fsNejr.d.ts} +8 -54
- package/dist/self-improve-B1fsNejr.d.ts.map +1 -0
- package/dist/{define-agent-eval-B6uE3gNu.js → self-improve-C_Bcdmv8.js} +9 -97
- package/dist/self-improve-C_Bcdmv8.js.map +1 -0
- package/dist/{sequential-BhbTSxpt.d.ts → sequential-CHplorpC.d.ts} +2 -2
- package/dist/{sequential-BhbTSxpt.d.ts.map → sequential-CHplorpC.d.ts.map} +1 -1
- package/dist/{sequential-ux_XrjBf.js → sequential-DR-pnYQ7.js} +3 -3
- package/dist/{sequential-ux_XrjBf.js.map → sequential-DR-pnYQ7.js.map} +1 -1
- package/dist/{server-1fzBCxMh.js → server-aZFmRucn.js} +3 -3
- package/dist/{server-1fzBCxMh.js.map → server-aZFmRucn.js.map} +1 -1
- package/dist/{skillopt-optimization-method-D_swD0Cy.js → skillopt-optimization-method-DHk1K757.js} +95 -40
- package/dist/skillopt-optimization-method-DHk1K757.js.map +1 -0
- package/dist/{statistical-heldout-CaS4T-43.js → statistical-heldout-CL_7mI5C.js} +3 -3
- package/dist/{statistical-heldout-CaS4T-43.js.map → statistical-heldout-CL_7mI5C.js.map} +1 -1
- package/dist/{statistics-DSidA5I2.js → statistics-AKnVFnK-.js} +233 -700
- package/dist/statistics-AKnVFnK-.js.map +1 -0
- package/dist/statistics.d.ts +3 -3
- package/dist/statistics.js +3 -2
- package/dist/{store-tool-spans-DniaFwjM.d.ts → store-tool-spans-M3WxeRrG.d.ts} +4 -4
- package/dist/{store-tool-spans-DniaFwjM.d.ts.map → store-tool-spans-M3WxeRrG.d.ts.map} +1 -1
- package/dist/{summary-report-CI4J6gxU.js → summary-report-DyBkOC6V.js} +15 -7
- package/dist/summary-report-DyBkOC6V.js.map +1 -0
- package/dist/summary-report-figures-CJHygLgw.d.ts.map +1 -1
- package/dist/supervisor-run/index.d.ts +12 -2
- package/dist/supervisor-run/index.d.ts.map +1 -1
- package/dist/supervisor-run/index.js +3 -3
- package/dist/{systemone-DzY-2Zri.d.ts → systemone-4PadCE4C.d.ts} +8 -7
- package/dist/systemone-4PadCE4C.d.ts.map +1 -0
- package/dist/{systemone-review-CXecR_m-.d.ts → systemone-review-DpAXWDkL.d.ts} +2 -2
- package/dist/{systemone-review-CXecR_m-.d.ts.map → systemone-review-DpAXWDkL.d.ts.map} +1 -1
- package/dist/systemone.d.ts +3 -3
- package/dist/systemone.js +1 -1
- package/dist/{tool-groups-DF6OqhoG.d.ts → tool-groups-SlnoQNyT.d.ts} +2 -2
- package/dist/tool-groups-SlnoQNyT.d.ts.map +1 -0
- package/dist/tool-waste-B01AMpID.d.ts +121 -0
- package/dist/tool-waste-B01AMpID.d.ts.map +1 -0
- package/dist/{tool-waste-u7JJ_BlE.js → tool-waste-BZnYSa6J.js} +3 -2
- package/dist/{tool-waste-u7JJ_BlE.js.map → tool-waste-BZnYSa6J.js.map} +1 -1
- package/dist/{trace-questions-DO8y3J-E.d.ts → trace-questions-ybyF0B6N.d.ts} +2 -2
- package/dist/{trace-questions-DO8y3J-E.d.ts.map → trace-questions-ybyF0B6N.d.ts.map} +1 -1
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/trace-repair/index.js +1 -1
- package/dist/traces.d.ts +4 -4
- package/dist/traces.js +1 -1
- package/dist/trajectory-B3o6Ald_.d.ts +100 -0
- package/dist/trajectory-B3o6Ald_.d.ts.map +1 -0
- package/dist/trajectory-replay/index.js +1 -1
- package/dist/{tree-DQMlcNFI.js → tree-CiIe-f3f.js} +6 -4
- package/dist/{tree-DQMlcNFI.js.map → tree-CiIe-f3f.js.map} +1 -1
- package/dist/{types-fuOwNq1C.d.ts → types-B1W3v8dT.d.ts} +3 -2
- package/dist/types-B1W3v8dT.d.ts.map +1 -0
- package/dist/{types-BMSDkS8l.d.ts → types-D5XtEH9Q.d.ts} +11 -4
- package/dist/{types-BMSDkS8l.d.ts.map → types-D5XtEH9Q.d.ts.map} +1 -1
- package/dist/types-DK4vNv5q.js.map +1 -1
- package/dist/{types-D_PfKC59.d.ts → types-an-CUndX.d.ts} +2 -2
- package/dist/{types-D_PfKC59.d.ts.map → types-an-CUndX.d.ts.map} +1 -1
- package/dist/{types-BLv2Ngla.d.ts → types-xVtEOBhO.d.ts} +31 -8
- package/dist/types-xVtEOBhO.d.ts.map +1 -0
- package/dist/wire/index.d.ts +2 -2
- package/dist/wire/index.js +1 -1
- package/dist/world/index.d.ts +529 -0
- package/dist/world/index.d.ts.map +1 -0
- package/dist/world/index.js +1356 -0
- package/dist/world/index.js.map +1 -0
- package/docs/campaign-proposers.md +7 -0
- package/docs/concepts.md +2 -0
- package/docs/design/statistics-decisions.md +48 -0
- package/docs/eval-surface-map.md +5 -2
- package/docs/feature-guide.md +3 -1
- package/docs/multi-turn-optimization.md +84 -0
- package/docs/outcome-validity.md +108 -0
- package/docs/public-api.md +89 -34
- package/docs/{multi-shot-optimization.md → trajectory-optimization.md} +1 -1
- package/docs/world.md +104 -0
- package/package.json +6 -1
- package/dist/analyze-runs-xjKBBqIB.d.ts.map +0 -1
- package/dist/benchmark-command-DkBMUDwy.js.map +0 -1
- package/dist/campaign-DfSWSreo.js.map +0 -1
- package/dist/cluster-Bj90LK-1.d.ts.map +0 -1
- package/dist/define-agent-eval-B6uE3gNu.js.map +0 -1
- package/dist/define-agent-eval-Cjc0wWnO.d.ts.map +0 -1
- package/dist/external-optimizer-subprocess-BW0ZWUUr.js.map +0 -1
- package/dist/index-C6TG1LwA.d.ts.map +0 -1
- package/dist/index-CKjqN9_U.d.ts.map +0 -1
- package/dist/index-DAFZRMlF.d.ts.map +0 -1
- package/dist/index-xEM_SoCl.d.ts.map +0 -1
- package/dist/interval-CWyxqDpE.d.ts +0 -43
- package/dist/interval-CWyxqDpE.d.ts.map +0 -1
- package/dist/llm-judge-DQJTQx01.js.map +0 -1
- package/dist/matrix-CqZSpwgN.d.ts.map +0 -1
- package/dist/outcome-observations-DL3CC8w1.js.map +0 -1
- package/dist/pareto-Bg75Gajo.js.map +0 -1
- package/dist/rollout-nodes-Vas6OSxX.js.map +0 -1
- package/dist/rubric-predictive-validity--6z0q8s6.js.map +0 -1
- package/dist/rubric-predictive-validity-C9wc7f_D.d.ts.map +0 -1
- package/dist/run-improvement-loop-BfwOUudy.d.ts.map +0 -1
- package/dist/run-record-Bqg0NZ_e.js.map +0 -1
- package/dist/runtime-rollouts-drQynu3t.js.map +0 -1
- package/dist/sequential-BphITa5b.js.map +0 -1
- package/dist/skillopt-optimization-method-D_swD0Cy.js.map +0 -1
- package/dist/statistics-DSidA5I2.js.map +0 -1
- package/dist/summary-report-CI4J6gxU.js.map +0 -1
- package/dist/systemone-DzY-2Zri.d.ts.map +0 -1
- package/dist/tool-groups-DF6OqhoG.d.ts.map +0 -1
- package/dist/tool-waste-CIhtU1ad.d.ts +0 -217
- package/dist/tool-waste-CIhtU1ad.d.ts.map +0 -1
- package/dist/types-BLv2Ngla.d.ts.map +0 -1
- package/dist/types-fuOwNq1C.d.ts.map +0 -1
|
@@ -1,107 +1,7 @@
|
|
|
1
1
|
import { s as ValidationError } from "./errors-DeEEV9Vx.js";
|
|
2
2
|
import { t as interpolatedQuantile } from "./quantile-CncXP-Ss.js";
|
|
3
|
+
import { A as regularizedIncompleteBeta, C as medianInPlace, D as studentTCdf, E as zQuantile, O as studentTQuantile, S as makeRng, T as symmetricTwoSampleSeed, b as assertFiniteSample, d as ranks, f as spearmanR, k as lnGamma, p as studentTCritical, u as pearsonR, w as seedFromData, x as binomialSignTwoSided } from "./paired-tests-CXcD_B80.js";
|
|
3
4
|
import { t as mulberry32 } from "./random-DrzcgC7F.js";
|
|
4
|
-
// src/math/special-functions.ts
|
|
5
|
-
/** Lanczos approximation to ln Gamma(z). */
|
|
6
|
-
function lnGamma(z) {
|
|
7
|
-
const g = 7;
|
|
8
|
-
const coefficients = [
|
|
9
|
-
.9999999999998099,
|
|
10
|
-
676.5203681218851,
|
|
11
|
-
-1259.1392167224028,
|
|
12
|
-
771.3234287776531,
|
|
13
|
-
-176.6150291621406,
|
|
14
|
-
12.507343278686905,
|
|
15
|
-
-.13857109526572012,
|
|
16
|
-
9984369578019572e-21,
|
|
17
|
-
1.5056327351493116e-7
|
|
18
|
-
];
|
|
19
|
-
if (z < .5) return Math.log(Math.PI / Math.sin(Math.PI * z)) - lnGamma(1 - z);
|
|
20
|
-
z -= 1;
|
|
21
|
-
let x = coefficients[0];
|
|
22
|
-
for (let i = 1; i < 9; i++) x += coefficients[i] / (z + i);
|
|
23
|
-
const t = z + g + .5;
|
|
24
|
-
return .5 * Math.log(2 * Math.PI) + (z + .5) * Math.log(t) - t + Math.log(x);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Regularized incomplete beta function I_x(a, b).
|
|
28
|
-
*
|
|
29
|
-
* The Lentz continued fraction converges only for `x < (a+1)/(a+b+2)`; outside
|
|
30
|
-
* that domain it must be reached through the symmetry `I_x(a,b) = 1 −
|
|
31
|
-
* I_{1−x}(b,a)`. `studentTCdf` drives `x → 1` as `|t| → 0`, so the mirrored
|
|
32
|
-
* branch is the one every near-null t-statistic takes.
|
|
33
|
-
*/
|
|
34
|
-
function regularizedIncompleteBeta(x, a, b) {
|
|
35
|
-
if (x <= 0) return 0;
|
|
36
|
-
if (x >= 1) return 1;
|
|
37
|
-
const logBeta = lnGamma(a) + lnGamma(b) - lnGamma(a + b);
|
|
38
|
-
const front = Math.exp(Math.log(x) * a + Math.log(1 - x) * b - logBeta);
|
|
39
|
-
if (x < (a + 1) / (a + b + 2)) return front * betaContinuedFraction(x, a, b) / a;
|
|
40
|
-
return 1 - front * betaContinuedFraction(1 - x, b, a) / b;
|
|
41
|
-
}
|
|
42
|
-
/** Modified Lentz evaluation of the beta continued fraction at `x`. */
|
|
43
|
-
function betaContinuedFraction(x, a, b) {
|
|
44
|
-
const maxIterations = 300;
|
|
45
|
-
const epsilon = 3e-15;
|
|
46
|
-
let c = 1;
|
|
47
|
-
let d = 1 - (a + b) * x / (a + 1);
|
|
48
|
-
if (Math.abs(d) < 1e-30) d = 1e-30;
|
|
49
|
-
d = 1 / d;
|
|
50
|
-
let fraction = d;
|
|
51
|
-
for (let m = 1; m <= maxIterations; m++) {
|
|
52
|
-
const m2 = 2 * m;
|
|
53
|
-
let numerator = m * (b - m) * x / ((a + m2 - 1) * (a + m2));
|
|
54
|
-
d = 1 + numerator * d;
|
|
55
|
-
if (Math.abs(d) < 1e-30) d = 1e-30;
|
|
56
|
-
c = 1 + numerator / c;
|
|
57
|
-
if (Math.abs(c) < 1e-30) c = 1e-30;
|
|
58
|
-
d = 1 / d;
|
|
59
|
-
fraction *= d * c;
|
|
60
|
-
numerator = -((a + m) * (a + b + m) * x) / ((a + m2) * (a + m2 + 1));
|
|
61
|
-
d = 1 + numerator * d;
|
|
62
|
-
if (Math.abs(d) < 1e-30) d = 1e-30;
|
|
63
|
-
c = 1 + numerator / c;
|
|
64
|
-
if (Math.abs(c) < 1e-30) c = 1e-30;
|
|
65
|
-
d = 1 / d;
|
|
66
|
-
const delta = d * c;
|
|
67
|
-
fraction *= delta;
|
|
68
|
-
if (Math.abs(delta - 1) < epsilon) break;
|
|
69
|
-
}
|
|
70
|
-
return fraction;
|
|
71
|
-
}
|
|
72
|
-
// src/math/student-t.ts
|
|
73
|
-
/**
|
|
74
|
-
* Student-t CDF via the regularized incomplete beta function.
|
|
75
|
-
*/
|
|
76
|
-
function studentTCdf(t, degreesOfFreedom) {
|
|
77
|
-
if (degreesOfFreedom <= 0) return .5;
|
|
78
|
-
const beta = regularizedIncompleteBeta(degreesOfFreedom / (degreesOfFreedom + t * t), degreesOfFreedom / 2, .5);
|
|
79
|
-
return t >= 0 ? 1 - .5 * beta : .5 * beta;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Inverse Student-t CDF, solved against {@link studentTCdf}.
|
|
83
|
-
*
|
|
84
|
-
* The CDF is monotone, so bracket expansion followed by bisection is stable
|
|
85
|
-
* across fractional degrees of freedom and does not need a separate
|
|
86
|
-
* approximation with a different error profile.
|
|
87
|
-
*/
|
|
88
|
-
function studentTQuantile(probability, degreesOfFreedom) {
|
|
89
|
-
if (!Number.isFinite(probability) || probability < 0 || probability > 1) throw new RangeError(`studentTQuantile: probability must be in [0,1], got ${probability}`);
|
|
90
|
-
if (!Number.isFinite(degreesOfFreedom) || degreesOfFreedom <= 0) throw new RangeError(`studentTQuantile: degreesOfFreedom must be positive and finite, got ${degreesOfFreedom}`);
|
|
91
|
-
if (probability === 0) return Number.NEGATIVE_INFINITY;
|
|
92
|
-
if (probability === 1) return Number.POSITIVE_INFINITY;
|
|
93
|
-
if (probability === .5) return 0;
|
|
94
|
-
if (probability < .5) return -studentTQuantile(1 - probability, degreesOfFreedom);
|
|
95
|
-
let low = 0;
|
|
96
|
-
let high = 1;
|
|
97
|
-
while (studentTCdf(high, degreesOfFreedom) < probability) high *= 2;
|
|
98
|
-
for (let iteration = 0; iteration < 64; iteration++) {
|
|
99
|
-
const middle = (low + high) / 2;
|
|
100
|
-
if (studentTCdf(middle, degreesOfFreedom) < probability) low = middle;
|
|
101
|
-
else high = middle;
|
|
102
|
-
}
|
|
103
|
-
return (low + high) / 2;
|
|
104
|
-
}
|
|
105
5
|
// src/statistics/cluster.ts
|
|
106
6
|
const DEFAULT_BOOTSTRAP_SEED = 12648430;
|
|
107
7
|
/** Percentile bootstrap; degenerate resamples are omitted, with NaN bounds if none remain. */
|
|
@@ -187,381 +87,6 @@ function placeboBand(history, options) {
|
|
|
187
87
|
high: q025 === null ? null : delta - q025
|
|
188
88
|
};
|
|
189
89
|
}
|
|
190
|
-
// src/statistics/internal.ts
|
|
191
|
-
/**
|
|
192
|
-
* Shared internals for the statistics modules. Nothing here is part of the
|
|
193
|
-
* public statistics surface — `./index` does not re-export this module.
|
|
194
|
-
*/
|
|
195
|
-
/** Every rank test refuses non-finite input. Beyond the arithmetic being
|
|
196
|
-
* undefined, the tie-grouping scan compares values with `===`, and
|
|
197
|
-
* `NaN === NaN` is false, so a NaN would leave the group boundary unable to
|
|
198
|
-
* advance and spin the loop forever. */
|
|
199
|
-
function assertFiniteSample(fn, label, xs) {
|
|
200
|
-
for (let i = 0; i < xs.length; i++) if (!Number.isFinite(xs[i])) throw new ValidationError(`${fn}: ${label}[${i}] must be finite, got ${xs[i]}`);
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Two-sided exact p-value for b successes out of (b + c) Bernoulli(0.5) trials —
|
|
204
|
-
* the exact-binomial core of {@link mcnemar}. `min(1, 2·P(X ≤ min(b,c)))`. No
|
|
205
|
-
* discordant pairs ⇒ no evidence ⇒ p = 1. Summed in log space (lnGamma) so it
|
|
206
|
-
* stays exact at large discordant counts without overflow.
|
|
207
|
-
*/
|
|
208
|
-
function binomialSignTwoSided(b, c) {
|
|
209
|
-
const nd = b + c;
|
|
210
|
-
if (nd === 0) return 1;
|
|
211
|
-
return Math.min(1, 2 * binomialHalfLowerTail(Math.min(b, c), nd));
|
|
212
|
-
}
|
|
213
|
-
/** P(X >= successes) for X ~ Binomial(n, 0.5). */
|
|
214
|
-
function binomialHalfUpperTail(successes, n) {
|
|
215
|
-
if (successes <= 0) return 1;
|
|
216
|
-
if (successes > n) return 0;
|
|
217
|
-
if (successes <= n / 2) return Math.max(0, 1 - binomialHalfLowerTail(successes - 1, n));
|
|
218
|
-
return binomialHalfLowerTail(n - successes, n);
|
|
219
|
-
}
|
|
220
|
-
/** P(X <= maxSuccesses) for X ~ Binomial(n, 0.5), accumulated in log space. */
|
|
221
|
-
function binomialHalfLowerTail(maxSuccesses, n) {
|
|
222
|
-
if (maxSuccesses < 0) return 0;
|
|
223
|
-
if (maxSuccesses >= n) return 1;
|
|
224
|
-
if (maxSuccesses === 0) return 2 ** -n;
|
|
225
|
-
const logHalfN = n * Math.log(.5);
|
|
226
|
-
let logTail = Number.NEGATIVE_INFINITY;
|
|
227
|
-
for (let i = 0; i <= maxSuccesses; i++) {
|
|
228
|
-
const logChoose = lnGamma(n + 1) - lnGamma(i + 1) - lnGamma(n - i + 1);
|
|
229
|
-
logTail = logAddExp(logTail, logChoose + logHalfN);
|
|
230
|
-
}
|
|
231
|
-
return Math.min(1, Math.exp(logTail));
|
|
232
|
-
}
|
|
233
|
-
function logAddExp(a, b) {
|
|
234
|
-
if (a === Number.NEGATIVE_INFINITY) return b;
|
|
235
|
-
if (b === Number.NEGATIVE_INFINITY) return a;
|
|
236
|
-
const max = Math.max(a, b);
|
|
237
|
-
return max + Math.log1p(Math.exp(Math.min(a, b) - max));
|
|
238
|
-
}
|
|
239
|
-
/** Standard-normal inverse CDF (Acklam approximation). */
|
|
240
|
-
function zQuantile(p) {
|
|
241
|
-
if (p <= 0 || p >= 1) {
|
|
242
|
-
if (p === 0) return -Infinity;
|
|
243
|
-
if (p === 1) return Infinity;
|
|
244
|
-
return NaN;
|
|
245
|
-
}
|
|
246
|
-
const a = [
|
|
247
|
-
-39.69683028665376,
|
|
248
|
-
220.9460984245205,
|
|
249
|
-
-275.9285104469687,
|
|
250
|
-
138.357751867269,
|
|
251
|
-
-30.66479806614716,
|
|
252
|
-
2.506628277459239
|
|
253
|
-
];
|
|
254
|
-
const b = [
|
|
255
|
-
-54.47609879822406,
|
|
256
|
-
161.5858368580409,
|
|
257
|
-
-155.6989798598866,
|
|
258
|
-
66.80131188771972,
|
|
259
|
-
-13.28068155288572
|
|
260
|
-
];
|
|
261
|
-
const c = [
|
|
262
|
-
-.007784894002430293,
|
|
263
|
-
-.3223964580411365,
|
|
264
|
-
-2.400758277161838,
|
|
265
|
-
-2.549732539343734,
|
|
266
|
-
4.374664141464968,
|
|
267
|
-
2.938163982698783
|
|
268
|
-
];
|
|
269
|
-
const d = [
|
|
270
|
-
.007784695709041462,
|
|
271
|
-
.3224671290700398,
|
|
272
|
-
2.445134137142996,
|
|
273
|
-
3.754408661907416
|
|
274
|
-
];
|
|
275
|
-
const pLow = .02425;
|
|
276
|
-
const pHigh = .97575;
|
|
277
|
-
let q;
|
|
278
|
-
let r;
|
|
279
|
-
if (p < pLow) {
|
|
280
|
-
q = Math.sqrt(-2 * Math.log(p));
|
|
281
|
-
return (((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q + c[4]) * q + c[5]) / ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1);
|
|
282
|
-
}
|
|
283
|
-
if (p <= pHigh) {
|
|
284
|
-
q = p - .5;
|
|
285
|
-
r = q * q;
|
|
286
|
-
return (((((a[0] * r + a[1]) * r + a[2]) * r + a[3]) * r + a[4]) * r + a[5]) * q / (((((b[0] * r + b[1]) * r + b[2]) * r + b[3]) * r + b[4]) * r + 1);
|
|
287
|
-
}
|
|
288
|
-
q = Math.sqrt(-2 * Math.log(1 - p));
|
|
289
|
-
return -(((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q + c[4]) * q + c[5]) / ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1);
|
|
290
|
-
}
|
|
291
|
-
function medianInPlace(xs) {
|
|
292
|
-
if (xs.length === 0) return 0;
|
|
293
|
-
xs.sort((a, b) => a - b);
|
|
294
|
-
return interpolatedQuantile(xs, .5);
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* PRNG for every resampling path in this module.
|
|
298
|
-
*
|
|
299
|
-
* With no caller seed the seed is DERIVED FROM THE DATA rather than taken from
|
|
300
|
-
* `Math.random`, so re-running the same input reproduces the same interval —
|
|
301
|
-
* a gate verdict that cannot be re-derived is not evidence. Distinct data
|
|
302
|
-
* still gets a distinct stream. Same pattern as `promotion-gate.ts`.
|
|
303
|
-
*/
|
|
304
|
-
function makeRng(seed, ...series) {
|
|
305
|
-
return mulberry32(seed ?? seedFromData(series));
|
|
306
|
-
}
|
|
307
|
-
/** FNV-1a over the IEEE-754 bytes of every observation. */
|
|
308
|
-
function seedFromData(series) {
|
|
309
|
-
const view = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
310
|
-
let hash = 2166136261;
|
|
311
|
-
for (const xs of series) {
|
|
312
|
-
for (const x of xs) {
|
|
313
|
-
view.setFloat64(0, x);
|
|
314
|
-
for (let byte = 0; byte < 8; byte++) hash = Math.imul(hash ^ view.getUint8(byte), 16777619);
|
|
315
|
-
}
|
|
316
|
-
hash = Math.imul(hash ^ 255, 16777619);
|
|
317
|
-
}
|
|
318
|
-
return hash | 0;
|
|
319
|
-
}
|
|
320
|
-
/** Order-independent seed for a symmetric two-sample statistic. */
|
|
321
|
-
function symmetricTwoSampleSeed(a, b) {
|
|
322
|
-
const sortedA = [...a].sort((left, right) => left - right);
|
|
323
|
-
const sortedB = [...b].sort((left, right) => left - right);
|
|
324
|
-
const forward = seedFromData([sortedA, sortedB]) >>> 0;
|
|
325
|
-
const reversed = seedFromData([sortedB, sortedA]) >>> 0;
|
|
326
|
-
return Math.min(forward, reversed);
|
|
327
|
-
}
|
|
328
|
-
// src/statistics/mean.ts
|
|
329
|
-
/** Arithmetic mean. An empty input has no mean and returns NaN. */
|
|
330
|
-
function mean(values) {
|
|
331
|
-
return values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
332
|
-
}
|
|
333
|
-
/** Arithmetic mean, or null for an empty input. */
|
|
334
|
-
function meanOrNull(values) {
|
|
335
|
-
return values.length === 0 ? null : mean(values);
|
|
336
|
-
}
|
|
337
|
-
/** Arithmetic mean, or 0 for an empty input. */
|
|
338
|
-
function meanOrZero(values) {
|
|
339
|
-
return values.length === 0 ? 0 : mean(values);
|
|
340
|
-
}
|
|
341
|
-
// src/statistics/descriptive.ts
|
|
342
|
-
/**
|
|
343
|
-
* Descriptive statistics: means, bootstrap spread, correlation, and the
|
|
344
|
-
* weighted judge-dimension composite. Nothing here is a significance test.
|
|
345
|
-
*/
|
|
346
|
-
/** Weighted mean — falls back to uniform weights when omitted */
|
|
347
|
-
function weightedMean(scores) {
|
|
348
|
-
if (scores.length === 0) return 0;
|
|
349
|
-
let totalWeight = 0;
|
|
350
|
-
let weightedSum = 0;
|
|
351
|
-
for (const { score, weight } of scores) {
|
|
352
|
-
const w = weight ?? 1;
|
|
353
|
-
weightedSum += score * w;
|
|
354
|
-
totalWeight += w;
|
|
355
|
-
}
|
|
356
|
-
return totalWeight > 0 ? weightedSum / totalWeight : 0;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Percentile bootstrap confidence interval on the mean of `scores`.
|
|
360
|
-
*
|
|
361
|
-
* Descriptive spread. It is not a significance test, and at small n its bounds
|
|
362
|
-
* are anti-conservative in the same way {@link pairedBootstrap}'s are — see
|
|
363
|
-
* {@link BOOTSTRAP_GATE_MIN_N}. With no `seed` the resampling is seeded from
|
|
364
|
-
* the scores themselves, so the interval is reproducible either way.
|
|
365
|
-
*/
|
|
366
|
-
function confidenceInterval(scores, confidence = .95, opts = {}) {
|
|
367
|
-
if (scores.length === 0) return {
|
|
368
|
-
mean: 0,
|
|
369
|
-
lower: 0,
|
|
370
|
-
upper: 0
|
|
371
|
-
};
|
|
372
|
-
if (scores.length === 1) return {
|
|
373
|
-
mean: scores[0],
|
|
374
|
-
lower: scores[0],
|
|
375
|
-
upper: scores[0]
|
|
376
|
-
};
|
|
377
|
-
const n = scores.length;
|
|
378
|
-
const mean = scores.reduce((a, b) => a + b, 0) / n;
|
|
379
|
-
const B = opts.resamples ?? 1e3;
|
|
380
|
-
const rng = makeRng(opts.seed, scores);
|
|
381
|
-
const bootstrapMeans = [];
|
|
382
|
-
for (let i = 0; i < B; i++) {
|
|
383
|
-
let sum = 0;
|
|
384
|
-
for (let j = 0; j < n; j++) sum += scores[Math.floor(rng() * n)];
|
|
385
|
-
bootstrapMeans.push(sum / n);
|
|
386
|
-
}
|
|
387
|
-
bootstrapMeans.sort((a, b) => a - b);
|
|
388
|
-
const alpha = 1 - confidence;
|
|
389
|
-
const lowerIdx = Math.floor(alpha / 2 * B);
|
|
390
|
-
const upperIdx = Math.floor((1 - alpha / 2) * B) - 1;
|
|
391
|
-
return {
|
|
392
|
-
mean,
|
|
393
|
-
lower: bootstrapMeans[lowerIdx],
|
|
394
|
-
upper: bootstrapMeans[Math.min(upperIdx, B - 1)]
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Two-sided Student-t critical value: the `t` with `P(|T| ≤ t) = confidence`
|
|
399
|
-
* for `df` degrees of freedom. Exact, from {@link studentTQuantile}, so any
|
|
400
|
-
* confidence in (0, 1) and fractional `df` are supported.
|
|
401
|
-
*/
|
|
402
|
-
function studentTCritical(df, confidence = .95) {
|
|
403
|
-
if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) throw new ValidationError(`studentTCritical: confidence must be in (0, 1), got ${confidence}`);
|
|
404
|
-
if (!Number.isFinite(df) || df <= 0) throw new ValidationError(`studentTCritical: df must be positive and finite, got ${df}`);
|
|
405
|
-
return studentTQuantile(1 - (1 - confidence) / 2, df);
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Student-t confidence interval on the mean of one sample:
|
|
409
|
-
* `mean ± t(df = n − 1) · s / √n`. Below two samples there is no spread to
|
|
410
|
-
* estimate, so the bounds are null rather than a zero-width interval that
|
|
411
|
-
* would read as certainty. Unlike {@link confidenceInterval} (a percentile
|
|
412
|
-
* bootstrap), the width keeps the small-n t penalty that z = 1.96 drops.
|
|
413
|
-
*/
|
|
414
|
-
function meanConfidenceInterval(samples, confidence = .95) {
|
|
415
|
-
assertFiniteSample("meanConfidenceInterval", "samples", samples);
|
|
416
|
-
const n = samples.length;
|
|
417
|
-
if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) throw new ValidationError(`meanConfidenceInterval: confidence must be in (0, 1), got ${confidence}`);
|
|
418
|
-
if (n < 2) return {
|
|
419
|
-
n,
|
|
420
|
-
mean: n === 0 ? null : samples[0],
|
|
421
|
-
stdev: null,
|
|
422
|
-
low: null,
|
|
423
|
-
high: null,
|
|
424
|
-
criticalValue: null
|
|
425
|
-
};
|
|
426
|
-
const center = mean(samples);
|
|
427
|
-
const sumSquares = samples.reduce((sum, value) => sum + (value - center) ** 2, 0);
|
|
428
|
-
const stdev = Math.sqrt(sumSquares / (n - 1));
|
|
429
|
-
const criticalValue = studentTCritical(n - 1, confidence);
|
|
430
|
-
const halfWidth = criticalValue * stdev / Math.sqrt(n);
|
|
431
|
-
return {
|
|
432
|
-
n,
|
|
433
|
-
mean: center,
|
|
434
|
-
stdev,
|
|
435
|
-
low: center - halfWidth,
|
|
436
|
-
high: center + halfWidth,
|
|
437
|
-
criticalValue
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
/** Partial credit: returns 0-1 ratio of current toward target */
|
|
441
|
-
function partialCredit(current, target) {
|
|
442
|
-
if (target <= 0) return 1;
|
|
443
|
-
return Math.min(1, Math.max(0, current / target));
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Fold a number series into its distribution summary. Quantiles use the
|
|
447
|
-
* nearest-rank definition — the `ceil(q·n)`-th order statistic — so every
|
|
448
|
-
* reported quantile is a value from the series. Returns `null` for an empty
|
|
449
|
-
* series: an empty series has no distribution, and a zero-filled summary
|
|
450
|
-
* would read as a measured all-zero series.
|
|
451
|
-
*/
|
|
452
|
-
function summarizeNumberSeries(values, options) {
|
|
453
|
-
const criticalValue = options?.medianInterval?.criticalValue;
|
|
454
|
-
if (options) {
|
|
455
|
-
assertFiniteSample("summarizeNumberSeries", "values", values);
|
|
456
|
-
for (const percentile of options.percentiles ?? []) if (!Number.isFinite(percentile) || percentile < 0 || percentile > 100) throw new ValidationError("summarizeNumberSeries: percentiles must be finite and between 0 and 100");
|
|
457
|
-
if (options.medianInterval && (criticalValue === void 0 || !Number.isFinite(criticalValue) || criticalValue < 0)) throw new ValidationError("summarizeNumberSeries: median criticalValue must be finite and nonnegative");
|
|
458
|
-
}
|
|
459
|
-
if (values.length === 0) return null;
|
|
460
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
461
|
-
const n = sorted.length;
|
|
462
|
-
const rank = (q) => sorted[Math.min(n - 1, Math.max(0, Math.ceil(q * n) - 1))];
|
|
463
|
-
const sum = sorted.reduce((a, b) => a + b, 0);
|
|
464
|
-
if (options && !Number.isFinite(sum)) throw new ValidationError("summarizeNumberSeries: sample sum exceeded finite range");
|
|
465
|
-
const spread = criticalValue === void 0 ? void 0 : criticalValue / 2 * Math.sqrt(n);
|
|
466
|
-
const lowRank = spread === void 0 ? 1 : Math.max(1, Math.floor(n / 2 - spread));
|
|
467
|
-
const highRank = spread === void 0 ? n : Math.min(n, Math.ceil(n / 2 + 1 + spread));
|
|
468
|
-
return {
|
|
469
|
-
n,
|
|
470
|
-
min: sorted[0],
|
|
471
|
-
p50: rank(.5),
|
|
472
|
-
p90: rank(.9),
|
|
473
|
-
max: sorted[sorted.length - 1],
|
|
474
|
-
sum,
|
|
475
|
-
...options?.percentiles === void 0 ? {} : { percentiles: Object.fromEntries(options.percentiles.map((percentile) => [percentile, rank(percentile / 100)])) },
|
|
476
|
-
...criticalValue === void 0 ? {} : { medianInterval: {
|
|
477
|
-
method: "normal-order-statistics",
|
|
478
|
-
criticalValue,
|
|
479
|
-
sampleSize: n,
|
|
480
|
-
lowRank,
|
|
481
|
-
highRank,
|
|
482
|
-
low: sorted[lowRank - 1],
|
|
483
|
-
high: sorted[highRank - 1]
|
|
484
|
-
} }
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Average-rank-with-ties transform (1-indexed). Tied values receive the mean
|
|
489
|
-
* of the ranks they span, the standard correction for Spearman's ρ.
|
|
490
|
-
*/
|
|
491
|
-
function ranks(xs) {
|
|
492
|
-
const indexed = xs.map((v, i) => ({
|
|
493
|
-
v,
|
|
494
|
-
i
|
|
495
|
-
})).sort((a, b) => a.v - b.v);
|
|
496
|
-
const r = new Array(xs.length);
|
|
497
|
-
let i = 0;
|
|
498
|
-
while (i < indexed.length) {
|
|
499
|
-
let j = i;
|
|
500
|
-
while (j + 1 < indexed.length && indexed[j + 1].v === indexed[i].v) j++;
|
|
501
|
-
const avg = (i + j) / 2 + 1;
|
|
502
|
-
for (let k = i; k <= j; k++) r[indexed[k].i] = avg;
|
|
503
|
-
i = j + 1;
|
|
504
|
-
}
|
|
505
|
-
return r;
|
|
506
|
-
}
|
|
507
|
-
/**
|
|
508
|
-
* Pearson product-moment correlation coefficient r ∈ [-1, 1] between two
|
|
509
|
-
* equal-length series. See the edge-case contract above: NaN for n < 2 or
|
|
510
|
-
* unequal lengths, 1 when both series are constant, 0 when exactly one is.
|
|
511
|
-
*/
|
|
512
|
-
function pearsonR(a, b) {
|
|
513
|
-
if (a.length !== b.length || a.length < 2) return NaN;
|
|
514
|
-
const n = a.length;
|
|
515
|
-
const meanA = a.reduce((s, v) => s + v, 0) / n;
|
|
516
|
-
const meanB = b.reduce((s, v) => s + v, 0) / n;
|
|
517
|
-
let num = 0;
|
|
518
|
-
let varA = 0;
|
|
519
|
-
let varB = 0;
|
|
520
|
-
for (let i = 0; i < n; i++) {
|
|
521
|
-
const da = a[i] - meanA;
|
|
522
|
-
const db = b[i] - meanB;
|
|
523
|
-
num += da * db;
|
|
524
|
-
varA += da * da;
|
|
525
|
-
varB += db * db;
|
|
526
|
-
}
|
|
527
|
-
if (varA === 0 || varB === 0) return varA === 0 && varB === 0 ? 1 : 0;
|
|
528
|
-
return num / Math.sqrt(varA * varB);
|
|
529
|
-
}
|
|
530
|
-
/**
|
|
531
|
-
* Spearman's rank correlation ρ — Pearson over the average-rank-with-ties
|
|
532
|
-
* transform of each series. Same edge-case contract as {@link pearsonR}.
|
|
533
|
-
*/
|
|
534
|
-
function spearmanR(a, b) {
|
|
535
|
-
if (a.length !== b.length || a.length < 2) return NaN;
|
|
536
|
-
return pearsonR(ranks(a), ranks(b));
|
|
537
|
-
}
|
|
538
|
-
/**
|
|
539
|
-
* Weighted composite over judge dimensions: `Σ(score_d · w_d) / Σ(w_d)` across
|
|
540
|
-
* the weighted dimensions. The canonical replacement for the per-consumer
|
|
541
|
-
* hand-rolled composite math (tax/legal/creative/gtm each ship a copy).
|
|
542
|
-
*
|
|
543
|
-
* Fail-loud: throws if a weighted dimension is missing from `dims`, if any
|
|
544
|
-
* weight is negative, or if the weights sum to 0 — none of which can produce
|
|
545
|
-
* a meaningful composite.
|
|
546
|
-
*/
|
|
547
|
-
function weightedComposite(input) {
|
|
548
|
-
const entries = Object.entries(input.weights);
|
|
549
|
-
if (entries.length === 0) throw new Error("weightedComposite: `weights` is empty — nothing to combine");
|
|
550
|
-
let weightedSum = 0;
|
|
551
|
-
let weightTotal = 0;
|
|
552
|
-
for (const [dim, weight] of entries) {
|
|
553
|
-
if (weight < 0) throw new Error(`weightedComposite: weight for '${dim}' is negative (${weight})`);
|
|
554
|
-
if (!(dim in input.dims)) throw new Error(`weightedComposite: weighted dimension '${dim}' is absent from \`dims\` — refusing to renormalise onto a different denominator`);
|
|
555
|
-
weightedSum += input.dims[dim] * weight;
|
|
556
|
-
weightTotal += weight;
|
|
557
|
-
}
|
|
558
|
-
if (weightTotal === 0) throw new Error("weightedComposite: weights sum to 0 — composite is undefined");
|
|
559
|
-
const composite = weightedSum / weightTotal;
|
|
560
|
-
return input.threshold === void 0 ? { composite } : {
|
|
561
|
-
composite,
|
|
562
|
-
pass: composite >= input.threshold
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
90
|
// src/judge-calibration.ts
|
|
566
91
|
/**
|
|
567
92
|
* Judge calibration — measure judge quality against human gold + bias.
|
|
@@ -1051,6 +576,212 @@ function cohenKappa(pairs) {
|
|
|
1051
576
|
kappa: expected === 1 ? NaN : (observed - expected) / (1 - expected)
|
|
1052
577
|
};
|
|
1053
578
|
}
|
|
579
|
+
// src/statistics/comparison-effects.ts
|
|
580
|
+
function binary(values, name) {
|
|
581
|
+
if (values.some((value) => value !== 0 && value !== 1)) throw new ValidationError(`${name}: expected binary 0/1 values`);
|
|
582
|
+
}
|
|
583
|
+
/** Mann–Whitney ROC area: ties count half; no observed member of either class means unknown. */
|
|
584
|
+
function rocAuc(scores, labels) {
|
|
585
|
+
assertFiniteSample("rocAuc", "scores", scores);
|
|
586
|
+
binary(labels, "rocAuc.labels");
|
|
587
|
+
if (scores.length !== labels.length) throw new ValidationError("rocAuc: scores and labels must have equal lengths");
|
|
588
|
+
const ranked = ranks(scores);
|
|
589
|
+
const positive = labels.reduce((sum, label) => sum + label, 0);
|
|
590
|
+
const sum = labels.reduce((total, label, index) => total + label * ranked[index], 0);
|
|
591
|
+
const negative = labels.length - positive;
|
|
592
|
+
return positive && negative ? (sum - positive * (positive + 1) / 2) / (positive * negative) : null;
|
|
593
|
+
}
|
|
594
|
+
// src/statistics/normalize-signed-zero.ts
|
|
595
|
+
/** Normalize IEEE negative zero before numerical evidence reaches canonical JSON. */
|
|
596
|
+
function normalizeSignedZero(value) {
|
|
597
|
+
return value === 0 ? 0 : value;
|
|
598
|
+
}
|
|
599
|
+
// src/statistics/clustered-association.ts
|
|
600
|
+
/**
|
|
601
|
+
* Association between a score and an outcome when rows share independent units.
|
|
602
|
+
*
|
|
603
|
+
* The interval and the standard error come from resampling whole units, never
|
|
604
|
+
* rows: rows of one unit share whatever makes that unit differ, and a row
|
|
605
|
+
* resample counts them as independent evidence. The p-value is a Wald test on
|
|
606
|
+
* that standard error with `units - 1` degrees of freedom, so it stays
|
|
607
|
+
* continuous for a false-discovery correction across many measures instead of
|
|
608
|
+
* stopping at the bootstrap's `1 / resamples` floor. When every defined
|
|
609
|
+
* resample gives the same value the standard error is zero and the p-value
|
|
610
|
+
* falls back to `1 / (definedResamples + 1)` for an estimate on the tested
|
|
611
|
+
* side of the null, and 1 otherwise.
|
|
612
|
+
*
|
|
613
|
+
* The stratified scope answers whether the score separates rows of the same
|
|
614
|
+
* stratum: AUC inside each stratum weighted by its positive-negative pairs, or
|
|
615
|
+
* Spearman inside each stratum weighted by its row pairs, where a score
|
|
616
|
+
* constant inside a stratum counts as no association there. A resample draws
|
|
617
|
+
* whole units and regroups their rows by stratum. The within-unit scope is the
|
|
618
|
+
* same statistic with each unit its own stratum, so a drawn unit is drawn with
|
|
619
|
+
* its stratum.
|
|
620
|
+
*/
|
|
621
|
+
function clusteredAssociation(rows, options) {
|
|
622
|
+
const { statistic } = options;
|
|
623
|
+
const scope = options.scope ?? "pooled";
|
|
624
|
+
const alternative = options.alternative ?? "two-sided";
|
|
625
|
+
const resamples = options.resamples ?? 1e3;
|
|
626
|
+
const confidence = options.confidence ?? .95;
|
|
627
|
+
if (statistic !== "auc" && statistic !== "spearman") throw new ValidationError("clusteredAssociation: statistic must be auc or spearman");
|
|
628
|
+
if (scope !== "pooled" && scope !== "within-unit" && scope !== "stratified") throw new ValidationError("clusteredAssociation: scope must be pooled, within-unit or stratified");
|
|
629
|
+
if (alternative !== "two-sided" && alternative !== "greater") throw new ValidationError("clusteredAssociation: alternative must be two-sided or greater");
|
|
630
|
+
if (!Number.isSafeInteger(resamples) || resamples < 1) throw new ValidationError("clusteredAssociation: resamples must be a positive safe integer");
|
|
631
|
+
for (const [index, row] of rows.entries()) {
|
|
632
|
+
if (!Number.isFinite(row.x) || !Number.isFinite(row.y)) throw new ValidationError(`clusteredAssociation: rows[${index}] must have finite x and y`);
|
|
633
|
+
if (statistic === "auc" && row.y !== 0 && row.y !== 1) throw new ValidationError(`clusteredAssociation: rows[${index}].y must be 0 or 1 for auc`);
|
|
634
|
+
if (typeof row.unit !== "string" || row.unit.length === 0) throw new ValidationError(`clusteredAssociation: rows[${index}].unit must be nonempty`);
|
|
635
|
+
if (scope === "stratified" && (typeof row.stratum !== "string" || row.stratum.length === 0)) throw new ValidationError(`clusteredAssociation: rows[${index}].stratum must be nonempty for the stratified scope`);
|
|
636
|
+
}
|
|
637
|
+
const seed = options.seed ?? seedFromData([rows.map((row) => row.x), rows.map((row) => row.y)]);
|
|
638
|
+
const draws = [];
|
|
639
|
+
const record = (value) => {
|
|
640
|
+
if (Number.isFinite(value)) draws.push(value);
|
|
641
|
+
return value;
|
|
642
|
+
};
|
|
643
|
+
let estimate;
|
|
644
|
+
let n;
|
|
645
|
+
let units;
|
|
646
|
+
let interval;
|
|
647
|
+
if (scope === "pooled") {
|
|
648
|
+
estimate = associationEstimate(statistic, rows);
|
|
649
|
+
n = rows.length;
|
|
650
|
+
units = new Set(rows.map((row) => row.unit)).size;
|
|
651
|
+
if (Number.isFinite(estimate) && units >= 2) interval = clusterBootstrap(rows, (row) => row.unit, (sample) => record(associationEstimate(statistic, sample)), {
|
|
652
|
+
resamples,
|
|
653
|
+
level: confidence,
|
|
654
|
+
seed
|
|
655
|
+
});
|
|
656
|
+
else interval = {
|
|
657
|
+
low: NaN,
|
|
658
|
+
high: NaN
|
|
659
|
+
};
|
|
660
|
+
} else if (scope === "within-unit") {
|
|
661
|
+
const summaries = stratumSummaries(statistic, rows, (row) => row.unit);
|
|
662
|
+
estimate = weightedMean(summaries);
|
|
663
|
+
n = summaries.reduce((sum, unit) => sum + unit.rows.length, 0);
|
|
664
|
+
units = summaries.length;
|
|
665
|
+
if (Number.isFinite(estimate) && units >= 2) interval = clusterBootstrap(summaries, (unit) => unit.stratum, (sample) => record(weightedMean(sample)), {
|
|
666
|
+
resamples,
|
|
667
|
+
level: confidence,
|
|
668
|
+
seed
|
|
669
|
+
});
|
|
670
|
+
else interval = {
|
|
671
|
+
low: NaN,
|
|
672
|
+
high: NaN
|
|
673
|
+
};
|
|
674
|
+
} else {
|
|
675
|
+
const summaries = stratumSummaries(statistic, rows, (row) => row.stratum);
|
|
676
|
+
estimate = weightedMean(summaries);
|
|
677
|
+
const contributing = summaries.flatMap((stratum) => stratum.rows);
|
|
678
|
+
n = contributing.length;
|
|
679
|
+
units = new Set(contributing.map((row) => row.unit)).size;
|
|
680
|
+
if (Number.isFinite(estimate) && units >= 2) interval = clusterBootstrap(rows, (row) => row.unit, (sample) => record(weightedMean(stratumSummaries(statistic, sample, (row) => row.stratum))), {
|
|
681
|
+
resamples,
|
|
682
|
+
level: confidence,
|
|
683
|
+
seed
|
|
684
|
+
});
|
|
685
|
+
else interval = {
|
|
686
|
+
low: NaN,
|
|
687
|
+
high: NaN
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
if (!Number.isFinite(estimate) || units < 2) throw new ValidationError(`clusteredAssociation: the ${scope} ${statistic} needs two units with both outcome classes for auc, or variation on both sides, in a comparable unit or stratum`);
|
|
691
|
+
const nullValue = statistic === "auc" ? .5 : 0;
|
|
692
|
+
const standardError = sampleStandardDeviation(draws);
|
|
693
|
+
const distance = estimate - nullValue;
|
|
694
|
+
let pValue;
|
|
695
|
+
if (!(standardError > 0)) pValue = (alternative === "greater" ? distance > 0 : distance !== 0) ? 1 / (draws.length + 1) : 1;
|
|
696
|
+
else if (alternative === "greater") pValue = 1 - studentTCdf(distance / standardError, units - 1);
|
|
697
|
+
else pValue = Math.min(1, 2 * (1 - studentTCdf(Math.abs(distance) / standardError, units - 1)));
|
|
698
|
+
return {
|
|
699
|
+
statistic,
|
|
700
|
+
scope,
|
|
701
|
+
alternative,
|
|
702
|
+
n,
|
|
703
|
+
units,
|
|
704
|
+
estimate: normalizeSignedZero(estimate),
|
|
705
|
+
null: nullValue,
|
|
706
|
+
standardError,
|
|
707
|
+
low: interval.low,
|
|
708
|
+
high: interval.high,
|
|
709
|
+
confidence,
|
|
710
|
+
pValue,
|
|
711
|
+
resamples,
|
|
712
|
+
definedResamples: draws.length
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* The point statistic alone, pooled, within units or within strata; NaN when
|
|
717
|
+
* it is undefined on these rows. Within units it needs `unit` on every row,
|
|
718
|
+
* within strata `stratum`.
|
|
719
|
+
*/
|
|
720
|
+
function associationEstimate(statistic, rows, scope = "pooled") {
|
|
721
|
+
if (scope !== "pooled") {
|
|
722
|
+
const key = scope === "within-unit" ? "unit" : "stratum";
|
|
723
|
+
return weightedMean(stratumSummaries(statistic, rows, (row) => row[key]));
|
|
724
|
+
}
|
|
725
|
+
const xs = rows.map((row) => row.x);
|
|
726
|
+
const ys = rows.map((row) => row.y);
|
|
727
|
+
if (statistic === "auc") return rocAuc(xs, ys) ?? NaN;
|
|
728
|
+
if (!varies(xs) || !varies(ys)) return NaN;
|
|
729
|
+
return spearmanR(xs, ys);
|
|
730
|
+
}
|
|
731
|
+
/** The statistic inside each stratum holding a comparable pair, with its pair-count weight. */
|
|
732
|
+
function stratumSummaries(statistic, rows, stratumOf) {
|
|
733
|
+
const byStratum = /* @__PURE__ */ new Map();
|
|
734
|
+
for (const row of rows) {
|
|
735
|
+
const key = stratumOf(row);
|
|
736
|
+
const members = byStratum.get(key);
|
|
737
|
+
if (members) members.push(row);
|
|
738
|
+
else byStratum.set(key, [row]);
|
|
739
|
+
}
|
|
740
|
+
const summaries = [];
|
|
741
|
+
for (const [stratum, members] of byStratum) {
|
|
742
|
+
const xs = members.map((row) => row.x);
|
|
743
|
+
const ys = members.map((row) => row.y);
|
|
744
|
+
if (statistic === "auc") {
|
|
745
|
+
const positive = ys.reduce((sum, y) => sum + y, 0);
|
|
746
|
+
const negative = ys.length - positive;
|
|
747
|
+
const value = rocAuc(xs, ys);
|
|
748
|
+
if (value === null) continue;
|
|
749
|
+
summaries.push({
|
|
750
|
+
stratum,
|
|
751
|
+
rows: members,
|
|
752
|
+
value,
|
|
753
|
+
weight: positive * negative
|
|
754
|
+
});
|
|
755
|
+
} else {
|
|
756
|
+
if (ys.length < 2 || !varies(ys)) continue;
|
|
757
|
+
summaries.push({
|
|
758
|
+
stratum,
|
|
759
|
+
rows: members,
|
|
760
|
+
value: varies(xs) ? spearmanR(xs, ys) : 0,
|
|
761
|
+
weight: ys.length * (ys.length - 1) / 2
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return summaries;
|
|
766
|
+
}
|
|
767
|
+
function weightedMean(summaries) {
|
|
768
|
+
let total = 0;
|
|
769
|
+
let weight = 0;
|
|
770
|
+
for (const summary of summaries) {
|
|
771
|
+
total += summary.value * summary.weight;
|
|
772
|
+
weight += summary.weight;
|
|
773
|
+
}
|
|
774
|
+
return weight > 0 ? total / weight : NaN;
|
|
775
|
+
}
|
|
776
|
+
function varies(values) {
|
|
777
|
+
return values.some((value) => value !== values[0]);
|
|
778
|
+
}
|
|
779
|
+
function sampleStandardDeviation(values) {
|
|
780
|
+
if (values.length < 2) return 0;
|
|
781
|
+
const mean = values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
782
|
+
const squares = values.reduce((sum, value) => sum + (value - mean) ** 2, 0);
|
|
783
|
+
return Math.sqrt(squares / (values.length - 1));
|
|
784
|
+
}
|
|
1054
785
|
// src/statistics/clustered-paired.ts
|
|
1055
786
|
const groupsOf = (items, cluster) => {
|
|
1056
787
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -1233,21 +964,6 @@ function simulateClusteredBinaryContrast(design) {
|
|
|
1233
964
|
simulatedPowerSe: detected.se
|
|
1234
965
|
};
|
|
1235
966
|
}
|
|
1236
|
-
// src/statistics/comparison-effects.ts
|
|
1237
|
-
function binary(values, name) {
|
|
1238
|
-
if (values.some((value) => value !== 0 && value !== 1)) throw new ValidationError(`${name}: expected binary 0/1 values`);
|
|
1239
|
-
}
|
|
1240
|
-
/** Mann–Whitney ROC area: ties count half; no observed member of either class means unknown. */
|
|
1241
|
-
function rocAuc(scores, labels) {
|
|
1242
|
-
assertFiniteSample("rocAuc", "scores", scores);
|
|
1243
|
-
binary(labels, "rocAuc.labels");
|
|
1244
|
-
if (scores.length !== labels.length) throw new ValidationError("rocAuc: scores and labels must have equal lengths");
|
|
1245
|
-
const ranked = ranks(scores);
|
|
1246
|
-
const positive = labels.reduce((sum, label) => sum + label, 0);
|
|
1247
|
-
const sum = labels.reduce((total, label, index) => total + label * ranked[index], 0);
|
|
1248
|
-
const negative = labels.length - positive;
|
|
1249
|
-
return positive && negative ? (sum - positive * (positive + 1) / 2) / (positive * negative) : null;
|
|
1250
|
-
}
|
|
1251
967
|
// src/statistics/distribution-summary.ts
|
|
1252
968
|
/** Nearest-rank percentile on a sorted, non-empty sample (0-100 scale). */
|
|
1253
969
|
function nearestRank(sorted, percentile) {
|
|
@@ -1929,219 +1645,33 @@ function pairedBinaryScale(before, after) {
|
|
|
1929
1645
|
* form. Requires 1 ≤ k ≤ n and 0 ≤ c ≤ n.
|
|
1930
1646
|
*/
|
|
1931
1647
|
function passAtK(n, c, k) {
|
|
1932
|
-
|
|
1933
|
-
if (k < 1 || k > n || c < 0 || c > n) throw new Error(`passAtK: require 1 ≤ k ≤ n and 0 ≤ c ≤ n (got n=${n}, c=${c}, k=${k})`);
|
|
1648
|
+
assertPassKArguments("passAtK", n, c, k);
|
|
1934
1649
|
if (n - c < k) return 1;
|
|
1935
1650
|
let prob = 1;
|
|
1936
1651
|
for (let i = n - c + 1; i <= n; i++) prob *= 1 - k / i;
|
|
1937
1652
|
return 1 - prob;
|
|
1938
1653
|
}
|
|
1939
|
-
// src/statistics/paired-tests.ts
|
|
1940
|
-
/**
|
|
1941
|
-
* Paired significance tests on continuous scores: the paired t-test, the
|
|
1942
|
-
* promotion-gate paired bootstrap, the exact sign test, and the package-wide
|
|
1943
|
-
* paired-delta decision statistic.
|
|
1944
|
-
*/
|
|
1945
|
-
/**
|
|
1946
|
-
* Paired t-test — before/after measurements on the SAME items.
|
|
1947
|
-
* Pairing removes inter-item variance, giving tighter significance than
|
|
1948
|
-
* an unpaired test when comparing prompt v1 vs prompt v2 on identical
|
|
1949
|
-
* scenarios.
|
|
1950
|
-
*
|
|
1951
|
-
* Returns `t = p = null` where the statistic is undefined: fewer than two
|
|
1952
|
-
* pairs, or a non-zero constant delta whose observed variance is zero. A
|
|
1953
|
-
* constant shift carries no information about the variance it would have to
|
|
1954
|
-
* be compared against, so the honest answer is "undefined", not `p = 0` —
|
|
1955
|
-
* three observations cannot buy absolute certainty. This is the same contract
|
|
1956
|
-
* {@link pairedCohensDz} states for the same condition. An all-zero delta is
|
|
1957
|
-
* different: it is a measured null, and returns `t = 0, p = 1`.
|
|
1958
|
-
*/
|
|
1959
|
-
function pairedTTest(before, after) {
|
|
1960
|
-
if (before.length !== after.length) throw new ValidationError(`pairedTTest: unequal sample sizes (${before.length} vs ${after.length})`);
|
|
1961
|
-
assertFiniteSample("pairedTTest", "before", before);
|
|
1962
|
-
assertFiniteSample("pairedTTest", "after", after);
|
|
1963
|
-
const n = before.length;
|
|
1964
|
-
if (n < 2) return {
|
|
1965
|
-
t: null,
|
|
1966
|
-
df: 0,
|
|
1967
|
-
p: null
|
|
1968
|
-
};
|
|
1969
|
-
const diffs = before.map((b, i) => after[i] - b);
|
|
1970
|
-
const mean = diffs.reduce((a, b) => a + b, 0) / n;
|
|
1971
|
-
const variance = diffs.reduce((acc, d) => acc + (d - mean) ** 2, 0) / (n - 1);
|
|
1972
|
-
const se = Math.sqrt(variance / n);
|
|
1973
|
-
if (se === 0) return mean === 0 ? {
|
|
1974
|
-
t: 0,
|
|
1975
|
-
df: n - 1,
|
|
1976
|
-
p: 1
|
|
1977
|
-
} : {
|
|
1978
|
-
t: null,
|
|
1979
|
-
df: n - 1,
|
|
1980
|
-
p: null
|
|
1981
|
-
};
|
|
1982
|
-
const t = mean / se;
|
|
1983
|
-
const df = n - 1;
|
|
1984
|
-
return {
|
|
1985
|
-
t,
|
|
1986
|
-
df,
|
|
1987
|
-
p: 2 * (1 - studentTCdf(Math.abs(t), df))
|
|
1988
|
-
};
|
|
1989
|
-
}
|
|
1990
|
-
/**
|
|
1991
|
-
* Pairs below which a percentile bootstrap interval is descriptive spread only.
|
|
1992
|
-
*
|
|
1993
|
-
* `P(low > 0)` under a true null, against a nominal 2.5 %, measured over 4000
|
|
1994
|
-
* seeded trials: 13.53 % at n = 3, 3.52 % at n = 10, 3.10 % at n = 20 on the
|
|
1995
|
-
* median; 13.85 %, 4.90 %, 3.80 % on the mean. This is intrinsic to resampling
|
|
1996
|
-
* three points, not an implementation error — scipy's BCa gives 16.0 % on the
|
|
1997
|
-
* same n = 3 data — so no change to the estimator moves it. Below this floor
|
|
1998
|
-
* the decision belongs to the exact sign test or exact signed-rank test.
|
|
1999
|
-
*/
|
|
2000
|
-
const BOOTSTRAP_GATE_MIN_N = 20;
|
|
2001
|
-
/**
|
|
2002
|
-
* Paired bootstrap on (after − before) deltas. Returns a CI on the chosen
|
|
2003
|
-
* statistic (median by default); pairs are resampled with replacement. Throws
|
|
2004
|
-
* on unequal sample sizes.
|
|
2005
|
-
*
|
|
2006
|
-
* `low > threshold` carries the stated confidence ONLY at `n ≥
|
|
2007
|
-
* {@link BOOTSTRAP_GATE_MIN_N}`, which `gateEligible` reports. Below it the
|
|
2008
|
-
* check fires under a true null several times more often than nominal, so the
|
|
2009
|
-
* interval is descriptive spread and a promotion must not turn on it.
|
|
2010
|
-
*/
|
|
2011
|
-
function pairedBootstrap(before, after, opts = {}) {
|
|
2012
|
-
if (before.length !== after.length) throw new Error(`pairedBootstrap: unequal sample sizes (${before.length} vs ${after.length})`);
|
|
2013
|
-
const confidence = opts.confidence ?? .95;
|
|
2014
|
-
const resamples = opts.resamples ?? 2e3;
|
|
2015
|
-
const statistic = opts.statistic ?? "median";
|
|
2016
|
-
if (confidence <= 0 || confidence >= 1) throw new Error(`pairedBootstrap: confidence must be in (0,1), got ${confidence}`);
|
|
2017
|
-
const n = before.length;
|
|
2018
|
-
const deltas = before.map((b, i) => after[i] - b);
|
|
2019
|
-
const gateEligible = n >= 20;
|
|
2020
|
-
if (n === 0) return {
|
|
2021
|
-
n: 0,
|
|
2022
|
-
median: 0,
|
|
2023
|
-
mean: 0,
|
|
2024
|
-
low: 0,
|
|
2025
|
-
high: 0,
|
|
2026
|
-
confidence,
|
|
2027
|
-
resamples,
|
|
2028
|
-
gateEligible
|
|
2029
|
-
};
|
|
2030
|
-
if (n === 1) {
|
|
2031
|
-
const d = deltas[0];
|
|
2032
|
-
return {
|
|
2033
|
-
n: 1,
|
|
2034
|
-
median: d,
|
|
2035
|
-
mean: d,
|
|
2036
|
-
low: d,
|
|
2037
|
-
high: d,
|
|
2038
|
-
confidence,
|
|
2039
|
-
resamples,
|
|
2040
|
-
gateEligible
|
|
2041
|
-
};
|
|
2042
|
-
}
|
|
2043
|
-
const rng = makeRng(opts.seed, deltas);
|
|
2044
|
-
const samples = new Array(resamples);
|
|
2045
|
-
for (let b = 0; b < resamples; b++) if (statistic === "mean") {
|
|
2046
|
-
let sum = 0;
|
|
2047
|
-
for (let k = 0; k < n; k++) sum += deltas[Math.floor(rng() * n)];
|
|
2048
|
-
samples[b] = sum / n;
|
|
2049
|
-
} else {
|
|
2050
|
-
const acc = new Array(n);
|
|
2051
|
-
for (let k = 0; k < n; k++) acc[k] = deltas[Math.floor(rng() * n)];
|
|
2052
|
-
samples[b] = medianInPlace(acc);
|
|
2053
|
-
}
|
|
2054
|
-
samples.sort((a, b) => a - b);
|
|
2055
|
-
const alpha = 1 - confidence;
|
|
2056
|
-
const lowIdx = Math.floor(alpha / 2 * resamples);
|
|
2057
|
-
const highIdx = Math.min(resamples - 1, Math.ceil((1 - alpha / 2) * resamples) - 1);
|
|
2058
|
-
return {
|
|
2059
|
-
n,
|
|
2060
|
-
median: medianInPlace([...deltas]),
|
|
2061
|
-
mean: deltas.reduce((s, x) => s + x, 0) / n,
|
|
2062
|
-
low: samples[lowIdx],
|
|
2063
|
-
high: samples[Math.max(highIdx, lowIdx)],
|
|
2064
|
-
confidence,
|
|
2065
|
-
resamples,
|
|
2066
|
-
gateEligible
|
|
2067
|
-
};
|
|
2068
|
-
}
|
|
2069
1654
|
/**
|
|
2070
|
-
*
|
|
2071
|
-
*
|
|
2072
|
-
*
|
|
2073
|
-
*
|
|
2074
|
-
*
|
|
2075
|
-
*
|
|
2076
|
-
*
|
|
2077
|
-
*
|
|
2078
|
-
* empty inputs return p = 1. Every input difference must be finite, and the
|
|
2079
|
-
* direction must be chosen explicitly so a caller cannot select it after
|
|
2080
|
-
* seeing the signs.
|
|
1655
|
+
* Unbiased pass^k (Yao et al. 2024, τ-bench): the probability that every one
|
|
1656
|
+
* of a random k of the `n` independent attempts at one task passes, given `c`
|
|
1657
|
+
* of them passed — C(c, k) / C(n, k). With n = k it is 1 when all k passed and
|
|
1658
|
+
* 0 otherwise: success in all k of k repeats. pass@k rewards one lucky attempt;
|
|
1659
|
+
* pass^k charges every unreliable one, so the two diverge exactly on tasks that
|
|
1660
|
+
* pass in some repeats only. Average the per-task values across the suite.
|
|
1661
|
+
* Shares `passAtK`'s argument rules; computed in product form, so no factorial
|
|
1662
|
+
* overflows.
|
|
2081
1663
|
*/
|
|
2082
|
-
function
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
let
|
|
2086
|
-
let
|
|
2087
|
-
|
|
2088
|
-
const difference = differences[i];
|
|
2089
|
-
if (!Number.isFinite(difference)) throw new ValidationError(`pairedSignTest: difference at index ${i} must be finite, got ${difference}`);
|
|
2090
|
-
if (difference > 0) positive++;
|
|
2091
|
-
else if (difference < 0) negative++;
|
|
2092
|
-
else ties++;
|
|
2093
|
-
}
|
|
2094
|
-
const nNonTies = positive + negative;
|
|
2095
|
-
const successes = alternative === "greater" ? positive : negative;
|
|
2096
|
-
return {
|
|
2097
|
-
n: differences.length,
|
|
2098
|
-
positive,
|
|
2099
|
-
negative,
|
|
2100
|
-
ties,
|
|
2101
|
-
nNonTies,
|
|
2102
|
-
alternative,
|
|
2103
|
-
pValue: binomialHalfUpperTail(successes, nNonTies)
|
|
2104
|
-
};
|
|
1664
|
+
function passHatK(n, c, k) {
|
|
1665
|
+
assertPassKArguments("passHatK", n, c, k);
|
|
1666
|
+
if (c < k) return 0;
|
|
1667
|
+
let prob = 1;
|
|
1668
|
+
for (let i = 0; i < k; i++) prob *= (c - i) / (n - i);
|
|
1669
|
+
return prob;
|
|
2105
1670
|
}
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
if (before.length !== after.length) throw new Error(`pairedDeltaTieFraction: unequal sample sizes (${before.length} vs ${after.length})`);
|
|
2110
|
-
const n = before.length;
|
|
2111
|
-
if (n === 0) return 0;
|
|
2112
|
-
let ties = 0;
|
|
2113
|
-
for (let i = 0; i < n; i++) if (Math.abs(after[i] - before[i]) < 1e-9) ties++;
|
|
2114
|
-
return ties / n;
|
|
1671
|
+
function assertPassKArguments(name, n, c, k) {
|
|
1672
|
+
if (!Number.isInteger(n) || !Number.isInteger(c) || !Number.isInteger(k)) throw new Error(`${name}: n, c, k must be integers (got n=${n}, c=${c}, k=${k})`);
|
|
1673
|
+
if (k < 1 || k > n || c < 0 || c > n) throw new Error(`${name}: require 1 ≤ k ≤ n and 0 ≤ c ≤ n (got n=${n}, c=${c}, k=${k})`);
|
|
2115
1674
|
}
|
|
2116
|
-
/**
|
|
2117
|
-
* The paired-delta statistic a DECISION is computed on, package-wide.
|
|
2118
|
-
*
|
|
2119
|
-
* The mean paired delta is the estimator that answers the question a promotion
|
|
2120
|
-
* gate asks — "by how much did the candidate move the score" — in the caller's
|
|
2121
|
-
* own units, and it equals the aggregate lift everyone quotes. The MEDIAN
|
|
2122
|
-
* answers a different question and loses the answer to this one in every regime
|
|
2123
|
-
* eval data actually lands in:
|
|
2124
|
-
* - TWO-POINT (pass/fail) outcomes on any encoding: the delta vector lives in
|
|
2125
|
-
* {−s, 0, +s} dominated by zeros, so the median and its whole bootstrap CI
|
|
2126
|
-
* are pinned at exactly 0 however large the shift. (Decide these on
|
|
2127
|
-
* {@link pairedRiskDifferenceExact} instead — same estimand, exact interval.)
|
|
2128
|
-
* - TIE-DOMINATED outcomes: at half the pairs tied the sample median is 0 by
|
|
2129
|
-
* construction, and `ci.low > threshold` then answers "no" forever at a
|
|
2130
|
-
* non-negative threshold and "yes" forever at a negative one.
|
|
2131
|
-
* - LOW-CARDINALITY outcomes, even well below half ties: judge dimensions on
|
|
2132
|
-
* integer 0-100, and block scores like {⅔, 1} from averaging pass/fail
|
|
2133
|
-
* leaves, put the median on a coarse lattice whose bootstrap percentiles
|
|
2134
|
-
* land on atoms. Measured: 26 blocks of 3 pass/fail leaves carrying a real
|
|
2135
|
-
* +12.8pp lift, only 23% of pairs tied, gives a median CI of [0, 0.333] —
|
|
2136
|
-
* lower bound exactly 0, so a gate at threshold 0 refuses a real lift.
|
|
2137
|
-
* That last case is why there is no tie-fraction threshold here: any cutoff on
|
|
2138
|
-
* ties leaves the lattice case open on the other side of it.
|
|
2139
|
-
*
|
|
2140
|
-
* `heldoutSignificance` has defaulted to the mean since #316 for the same
|
|
2141
|
-
* reason. The median remains available per call site for callers who
|
|
2142
|
-
* specifically want outlier robustness and accept the blindness.
|
|
2143
|
-
*/
|
|
2144
|
-
const DECISION_PAIRED_DELTA_STATISTIC = "mean";
|
|
2145
1675
|
// src/statistics/power-and-mde.ts
|
|
2146
1676
|
/**
|
|
2147
1677
|
* Required N per arm for a two-sample comparison at target effect size,
|
|
@@ -2154,7 +1684,8 @@ function requiredSampleSize(opts) {
|
|
|
2154
1684
|
if (!Number.isFinite(effect) || effect <= 0) return Infinity;
|
|
2155
1685
|
const alpha = opts.alpha ?? .05;
|
|
2156
1686
|
const power = opts.power ?? .8;
|
|
2157
|
-
const
|
|
1687
|
+
const twoSided = opts.twoSided ?? true;
|
|
1688
|
+
const n = 2 * ((zQuantile(twoSided ? 1 - alpha / 2 : 1 - alpha) + zQuantile(power)) / effect) ** 2;
|
|
2158
1689
|
return Math.ceil(n);
|
|
2159
1690
|
}
|
|
2160
1691
|
/**
|
|
@@ -2171,7 +1702,8 @@ function requiredPairedSampleSize(opts) {
|
|
|
2171
1702
|
if (!Number.isFinite(effect) || effect <= 0) return Infinity;
|
|
2172
1703
|
const alpha = opts.alpha ?? .05;
|
|
2173
1704
|
const power = opts.power ?? .8;
|
|
2174
|
-
const
|
|
1705
|
+
const twoSided = opts.twoSided ?? true;
|
|
1706
|
+
const zAlpha = zQuantile(twoSided ? 1 - alpha / 2 : 1 - alpha);
|
|
2175
1707
|
const zBeta = zQuantile(power);
|
|
2176
1708
|
return Math.ceil(((zAlpha + zBeta) / effect) ** 2);
|
|
2177
1709
|
}
|
|
@@ -2185,7 +1717,8 @@ function pairedMde(opts) {
|
|
|
2185
1717
|
if (!Number.isFinite(opts.nPaired) || opts.nPaired <= 0) return Infinity;
|
|
2186
1718
|
const alpha = opts.alpha ?? .05;
|
|
2187
1719
|
const power = opts.power ?? .8;
|
|
2188
|
-
|
|
1720
|
+
const twoSided = opts.twoSided ?? true;
|
|
1721
|
+
return (zQuantile(twoSided ? 1 - alpha / 2 : 1 - alpha) + zQuantile(power)) / Math.sqrt(opts.nPaired);
|
|
2189
1722
|
}
|
|
2190
1723
|
/**
|
|
2191
1724
|
* Number of paired observations needed for a McNemar test to reach a target
|
|
@@ -2811,6 +2344,6 @@ function assertResumable(resume, params) {
|
|
|
2811
2344
|
}
|
|
2812
2345
|
return resume;
|
|
2813
2346
|
}
|
|
2814
|
-
export {
|
|
2347
|
+
export { selfPreference as $, cliffsDelta as A, simulateClusteredBinaryContrast as B, chiSquared as C, normalTwoSidedPValue as D, linearRegressionSlope as E, summarizeDistribution as F, corpusInterRaterAgreement as G, clusteredAssociation as H, clusterJackknife as I, nominalAgreement as J, corpusInterRaterAgreementFromJudgeScores as K, clusterSignFlipTest as L, interpretCliffs as M, pairedCohensDz as N, studentTTwoSidedPValue as O, percentileNearestRank as P, positionalBias as Q, clusteredBinaryMde as R, holm as S, fisherExactTwoSided as T, normalizeSignedZero as U, associationEstimate as V, rocAuc as W, calibrateJudgeContinuous as X, calibrateJudge as Y, continuousAgreement as Z, passAtK as _, wilcoxonSignedRank as a, benjaminiHochberg as b, pairedMde as c, independentRiskDifference as d, verbosityBias as et, mcnemar as f, pairedRiskDifferenceScore as g, pairedRiskDifferenceExact as h, mannWhitneyU as i, cohensD as j, twoByTwoPValue as k, requiredPairedSampleSize as l, pairedRiskDifference as m, sampleMedian as n, clusterBootstrap as nt, mcnemarPower as o, pairedBinaryScale as p, interRaterReliability as q, summarizeSample as r, placeboBand as rt, mcnemarRequiredN as s, eProcess as t, DEFAULT_BOOTSTRAP_SEED as tt, requiredSampleSize as u, passHatK as v, chiSquaredPValue as w, bonferroni as x, wilson as y, clusteredPairedContrast as z };
|
|
2815
2348
|
|
|
2816
|
-
//# sourceMappingURL=statistics-
|
|
2349
|
+
//# sourceMappingURL=statistics-AKnVFnK-.js.map
|