Skip to content

Add statistics and A/B significance testing#273

Merged
JE-Chen merged 2 commits into
devfrom
feat/stats
Jun 20, 2026
Merged

Add statistics and A/B significance testing#273
JE-Chen merged 2 commits into
devfrom
feat/stats

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

ab_locator ranks strategies by raw success rate and run_history stores 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

  • Headless core: je_auto_control/utils/stats/
  • Facade: re-exported from __init__.py + __all__
  • Executor: AC_describe_stats, AC_ab_significance
  • MCP: ac_describe_stats, ac_ab_significance
  • Script Builder: "Describe Statistics" / "A/B Significance (z-test)" under Data

Tests & 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²)
  • v65 feature docs (EN + Zh) + toctree registration
  • What's-new sections in all three READMEs

Lint clean: ruff / pylint / bandit / radon (no function CC > 10).

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.
@codacy-production

codacy-production Bot commented Jun 20, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 68 complexity · 0 duplication

Metric Results
Complexity 68
Duplication 0

View in Codacy

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.

@JE-Chen JE-Chen merged commit bb609f3 into dev Jun 20, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/stats branch June 20, 2026 23:19
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant