Skip to content

dgb(phase-b): binomial confidence-interval SSOT + KAT (Wilson score, diagnostics-only) - #425

Merged
frstrtr merged 1 commit into
masterfrom
dgb/binomial-conf-ssot
Jun 24, 2026
Merged

dgb(phase-b): binomial confidence-interval SSOT + KAT (Wilson score, diagnostics-only)#425
frstrtr merged 1 commit into
masterfrom
dgb/binomial-conf-ssot

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 24, 2026

Copy link
Copy Markdown
Owner

FENCED, additive Phase-B pillar — the binomial-conf efficiency slice queued behind G3b #82-confirm.

What

Lifts p2pool util/math.py:133 binomial_conf_interval (Wilson score interval) + its ierf/erf (A&S 7.1.26) helpers into a header-only SSOT at src/impl/dgb/coin/binomial_conf_interval.hpp.

Scope / fence

  • DIAGNOSTICS ONLY: this is the stale-rate / dead-share confidence-interval display math the status loop renders (main.py:406/425/426 via format_binomial_conf). No PoW / share format / sharechain rule / PPLNS / block submission touched -> p2pool-merged-v36 surface: NONE.
  • DGB tree only (src/impl/dgb/coin/ + src/impl/dgb/test/) + both build.yml --target allowlist sites. No bitcoin_family, no src/core, no other coin tree. share_tracker.hpp NOT rewired (byte-identity delegation, if ever wanted, is a separate follow-on).

Faithfulness

The oracle does not use libm erf — it ships its own A&S-7.1.26 polynomial and Newton-iterates ierf on it. The port reproduces that exact erf (so the quantile matches) and the add_to_range step (interval extended to bracket the point estimate) before clipping to [0,1].

Proof — KAT 8/8, NON-CIRCULAR

Golden interval endpoints are captured from the actual Python oracle, not recomputed from the C++ port:

  • z(0.95)=1.95996, z(0.6826)=0.99982 quantile cross-checks (validates ierf/erf)
  • oracle goldens for (5/100), (0/100 lower-clip), (50/100 symmetric), (10/50 @0.6826), (3/1000)
  • structural invariant: interval always brackets p=x/n and stays in [0,1]

Header-only (<cmath>/<array>) -> links only GTest. GPG-signed, no attribution. NO self-merge — integrator taps.

Lift the p2pool util/math.py:133 binomial_conf_interval (Wilson score
interval) and its ierf/erf A&S-7.1.26 helpers into a fenced, header-only
SSOT at src/impl/dgb/coin/binomial_conf_interval.hpp. This is the
stale-rate / dead-share confidence-interval display arithmetic the status
loop renders (main.py:406/425/426 via format_binomial_conf) -- diagnostics
only, no PoW / share / sharechain / PPLNS / block-submission surface, so
the p2pool-merged-v36 surface is NONE. No call site is rewired.

Faithful to the oracle: ships the oracle A&S-7.1.26 erf approximation (not
libm erf) so the 10-step Newton ierf root reproduces the oracle quantile,
and reproduces add_to_range (interval extended to bracket the point
estimate) before clipping to [0,1].

KAT pins golden interval endpoints captured from the actual Python oracle
(non-circular) plus the z(0.95)=1.95996 / z(0.6826)=0.99982 quantile
cross-checks and structural invariants. 8/8 green. Header-only -> links
only GTest. Added to both build.yml --target allowlist sites (#143 trap).
@frstrtr
frstrtr merged commit 8bd1407 into master Jun 24, 2026
32 checks passed
frstrtr added a commit that referenced this pull request Jun 25, 2026
…-on) (#507)

node.cpp format_binomial_conf{,_efficiency} carried an inline z=1.96 +
plain-[0,1]-clip Wilson-score approximation that duplicated, and slightly
diverged from, the oracle-faithful coin/binomial_conf_interval.hpp SSOT
(z = sqrt(2)*ierf(conf), add_to_range bracketing; p2pool util/math.py:133).

Delegate both diag formatters onto the SSOT. Diagnostics only (heartbeat
log stale-rate/efficiency display) -- zero consensus surface, no block
reward path. Underlying math is now oracle-faithful; rendered output is
empirically byte-identical across 13 representative (x,n) cases (the
sub-integer-percent z/bracket delta washes out under floor/ceil-to-percent
rendering). NOT strictly double-level byte-identical -- see PR note.

Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
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