Skip to content

v0.3.0 — two_sample_test

Latest

Choose a tag to compare

@TYEclipse TYEclipse released this 20 Oct 21:49

dsh-probstat v0.3.0

Two independent groups, compared deterministically. New tool two_sample_test joins the six existing ones.

New: two_sample_test

Compare two groups without hand-waving — both estimates, the difference, the standard error, the statistic, the df, all three p-values, the tail-specific critical value and the decision come back together:

kind when to use it null distribution
mean_z difference of means, population sigmas known normal
mean_welch difference of means, sigmas unknown, unequal variances Student-t, Welch–Satterthwaite df
mean_pooled difference of means, unknown sigmas, equal-variance assumption Student-t, df = n₁ + n₂ − 2
proportion difference of two proportions normal, pooled proportion
  • delta0 sets the null-hypothesis difference (default 0), so non-inferiority style questions work without reshaping the data.
  • The Welch df is fractional and reported unrounded — rounding it to an integer silently moves the p-value.
  • pooledVariance / pooledProportion are reported so the equal-variance / homogeneous-proportion assumption is checkable rather than assumed.
  • A shaky normal approximation (smallest expected cell < 5) is flagged in note; a zero standard error (both groups all-success or all-fail) is an error, not a fake statistic.
kind: "mean_welch", mean1: 5.2, mean2: 4.6, sd1: 1.1, sd2: 0.9, n1: 12, n2: 15
→ t 1.5248215, df 21.166825, two-sided p 0.1421069, critical 2.0786163 → do not reject at 0.05

Verification

  • 59 tests (was 50), coverage 86.97% → 88.12%.
  • Every numeric expectation comes from the in-repo oracle test/oracle/anchors.py; the new section computes the t tail by Simpson quadrature on the t density instead of the continued-fraction incomplete beta used by the plugin — a shared mistake cannot pass both sides. Cross-checked against published t-table values (2.228138852 / 2.042272456 / 1.795884819).
  • Oracle self-check covers invariants: p-values in [0, 1], two-sided = 2 × smaller tail, Welch df < pooled df on unequal variances, pooled variance = df-weighted mean of the two variances, pooled proportion = total successes over total n.

安装 / Install:

dsh plugin --profile web add github:TYEclipse/dsh-probstat#v0.3.0

中文摘要

新增 two_sample_test:双样本检验,一次给出两组估计、差值、标准误、统计量、自由度、三个 p 值与 α 判定。

  • 四种口径:均值差(σ 已知 z / σ 未知 Welch / 等方差合并方差 t)+ 双比例差(合并比例正态近似)。
  • Welch 自由度按 Welch–Satterthwaite 原值报告不取整(取整会静默改变 p 值)。
  • 合并方差与合并比例一并给出,假设可核对;比例口径最小期望单元格 < 5 时提示近似不可靠;标准误为 0 时报错而不给无意义统计量。
  • 测试 50 → 59,覆盖率 86.97% → 88.12%;期望值全部由仓内 oracle 生成,新区的 t 尾概率改用 Simpson 数值积分独立实现,并与公开 t 表值交叉验证。