Repository navigation
Releases: TYEclipse/dsh-probstat
Release list
v0.3.0 — two_sample_test
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 |
delta0sets the null-hypothesis difference (default0), 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/pooledProportionare 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 表值交叉验证。
v0.2.0
dsh-probstat v0.2.0
Two new tools — the "what does this data actually say?" half of statistics, next to the existing distribution/interval math.
EN
hypothesis_test— one-sample tests with the decision spelled out:mean_z(known sigma),mean_t(unknown sigma, Student-t with df = n − 1) andproportion(againstp0, normal approximation). Each run returns the statistic, the standard error, all three p-values (two-sided / left / right), the critical value for the requestedtail, and whether the null is rejected atalpha(default 0.05). The proportion kind adds anotewhenn·p0 < 5instead of quietly handing back a p-value.sample_size— required sample size for a target margin of error:mean_zclosed form n = (z·σ/E)²,proportionvia the Wald closed form (method: "wald", default) or the smallest n whose Wilson half-width meets E (method: "wilson", binary search).pdefaults to 0.5, the conservative worst case; impossible targets returnvalid: falsewith the reason.
中文
hypothesis_test:单样本假设检验——σ 已知走 z、σ 未知走 t(df = n−1)、单比例检验(对 p0 的正态近似)。一次给出统计量、标准误、三个 p 值(双侧/左/右)、所请求尾部的临界值与 α 判定(默认 0.05)。比例检验在 n·p0 < 5 时用note明确提示近似不可靠。sample_size:目标误差限所需样本量——均值闭式 n = (z·σ/E)²;比例可选 Wald 闭式(默认)或 Wilson 口径(二分求 Wilson 半宽 ≤ E 的最小 n);p默认 0.5(最保守),目标不可达时报错并说明原因。
Quality
- Tests 37 → 50; coverage 83.70% → 86.97% (baseline ratcheted up).
- Oracle moved to
test/oracle/anchors.py(independent Python implementation:math.erf,math.comb, bisection, independent t and Wilson code) with a--checkmode cross-validating published z/t-table constants. Every numeric assertion in the test file is generated there — including all legacy anchors. - The TS implementation and the Python oracle agree to the documented precision; the one place they differ in the 8th significant digit (a squared critical value) is pinned at 5 digits with the reason in the test.
Install:
dsh plugin --profile web add github:TYEclipse/dsh-probstatv0.1.0
v0.1.0 — initial release
First release of dsh-probstat: deterministic probability & statistical-inference math for DeepSeek Harness, zero runtime dependencies.
Four tools:
- dist_calc — pdf / cdf / survival / quantile / stats for six distributions: normal, binomial, poisson, exponential, uniform, geometric
- z_score — standard-normal table math: z ↔ probability/percentile, two-sided p-values, interval probabilities
- confidence_interval — mean intervals (known σ → z; unknown σ → Student-t, df = n−1) and proportion intervals (Wilson score method)
- event_probability — union / intersection / conditional / Bayes / complement / at-least-one identities
Numerics: normal cdf via A&S 7.1.26 erf fit (|err| ≤ 1.5e-7), quantile via Acklam inverse normal (rel. err < 1.15e-9); binomial/poisson exact recurrence summation; Student-t via Lentz continued fraction + Lanczos log-gamma, cross-checked against published t-table values. 37 tests, anchors generated by an independent Python oracle (test/anchors-probstat.py) and cross-validated with published z/t-table values.
v0.1.0 — 首发版本
dsh-probstat 首发:DeepSeek Harness 概率与统计推断数学工具箱,零运行时依赖。
四个工具:
- dist_calc — 六种分布(正态/二项/泊松/指数/均匀/几何)的 pdf / cdf / 生存函数 / 分位数 / 统计量
- z_score — 标准正态表换算:z ↔ 概率/百分位、双侧 p 值、区间概率
- confidence_interval — 均值置信区间(σ 已知走 z;未知走 t,df = n−1)+ 比例 Wilson 区间
- event_probability — 并 / 交 / 条件 / 贝叶斯 / 补集 / 至少一次成功恒等式
数值方法:正态 CDF 用 A&S 7.1.26 erf 拟合(绝对误差 ≤ 1.5e-7),分位数用 Acklam 逆正态(相对误差 < 1.15e-9);二项/泊松递推精确求和;t 分布用连分式不完全贝塔 + Lanczos log-Gamma,并与公开 t 表值交叉验证。37 项测试,锚点由独立 Python oracle(test/anchors-probstat.py)生成。
Install: dsh plugin --profile web add github:TYEclipse/dsh-probstat