dgb(phase-b): binomial confidence-interval SSOT + KAT (Wilson score, diagnostics-only) - #425
Merged
Merged
Conversation
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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) + itsierf/erf(A&S 7.1.26) helpers into a header-only SSOT atsrc/impl/dgb/coin/binomial_conf_interval.hpp.Scope / fence
main.py:406/425/426viaformat_binomial_conf). No PoW / share format / sharechain rule / PPLNS / block submission touched -> p2pool-merged-v36 surface: NONE.src/impl/dgb/coin/+src/impl/dgb/test/) + bothbuild.yml--target allowlist sites. Nobitcoin_family, nosrc/core, no other coin tree.share_tracker.hppNOT 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-iteratesierfon it. The port reproduces that exacterf(so the quantile matches) and theadd_to_rangestep (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.99982quantile cross-checks (validates ierf/erf)Header-only (
<cmath>/<array>) -> links only GTest. GPG-signed, no attribution. NO self-merge — integrator taps.