Repository navigation
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-probstat