Add statistics and A/B significance testing#273
Merged
Merged
Conversation
ab_locator ranks by raw success rate and run_history stores durations, but nothing computed percentiles or whether a difference is statistically significant. Add descriptive stats + percentiles, a two-proportion z-test with CI, Welch's t-test (exact t-distribution p-value via the incomplete beta, no SciPy), Cohen's d and a 2x2 chi-square. Normal CDF exact via erf; validated against textbook values. Wired through the facade, AC_describe_stats and AC_ab_significance executor commands, MCP tools and the Script Builder.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 68 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
ab_locatorranks strategies by raw success rate andrun_historystores durations, but nothing computed percentiles or told you whether a difference is statistically significant (vs. noise). This adds the analysis layer.percentile(values, q, method=)/describe(values)— summary stats + p50/p90/p95/p99.two_proportion_z_test(a_conv, a_n, b_conv, b_n)— conversion-rate test, pooled SE for the test + unpooled SE for the CI; returns{z, p_value, significant, diff, ci_low, ci_high}.welch_t_test(a, b)— continuous metrics, Welch–Satterthwaite df, exact t-distribution p-value via the regularized incomplete beta (no SciPy).cohens_d(a, b)— effect size;chi_square_2x2(...)— df=1 chi-square.Normal CDF exact via
math.erf. Validated against textbook values, including the chi²=z² identity. Pure stdlib (math+statistics).Five-layer wiring
je_auto_control/utils/stats/__init__.py+__all__AC_describe_stats,AC_ab_significanceac_describe_stats,ac_ab_significanceTests & docs
test/unit_test/headless/test_stats_batch.py(14 tests against textbook values: percentiles, z-test 90/200 vs 110/200 → p=0.0455, Welch sig/non-sig, chi²=z²)Lint clean: ruff / pylint / bandit / radon (no function CC > 10).