From: Forrest Voight Date: Mon, 23 Jan 2012 01:18:21 +0000 (-0500) Subject: improved estimation of stale proportion by using maximum-likelihood estimator instead... X-Git-Tag: 0.8.3~81 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=79b8a450216107e880bbb6ef8e790460cf5df164;p=p2pool.git improved estimation of stale proportion by using maximum-likelihood estimator instead of center of confidence interval --- diff --git a/p2pool/main.py b/p2pool/main.py index 76313e7..f844319 100644 --- a/p2pool/main.py +++ b/p2pool/main.py @@ -785,9 +785,12 @@ def main(args, net, datadir_path): conf = 0.95 if shares: stale_shares = stale_orphan_shares + stale_doa_shares - this_str += u' Own: %i±%i%%' % tuple(int(100*x+.5) for x in math.interval_to_center_radius(math.binomial_conf_interval(stale_shares, shares, conf))) + stale_center, stale_radius = math.binomial_conf_center_radius(stale_shares, shares, conf) + this_str += u' Own: %i±%i%%' % (int(100*stale_center+.5), int(100*stale_radius+.5)) if stale_prop < .99: - this_str += u' Own efficiency: %i±%i%%' % tuple(int(100*x+.5) for x in math.interval_to_center_radius((1 - y)/(1 - stale_prop) for y in math.binomial_conf_interval(stale_shares, shares, conf)[::-1])) + eff_center = (1 - stale_center)/(1 - stale_prop) + eff_radius = stale_radius/(1 - stale_prop) + this_str += u' Own efficiency: %i±%i%%' % (int(100*eff_center+.5), int(100*eff_radius+.5)) if this_str != last_str or time.time() > last_time + 15: print this_str last_str = this_str diff --git a/p2pool/util/math.py b/p2pool/util/math.py index 3600064..3c7af42 100644 --- a/p2pool/util/math.py +++ b/p2pool/util/math.py @@ -117,8 +117,11 @@ def binomial_conf_interval(x, n, conf=0.95): bottom = 1 + z**2/n return (topa - topb)/bottom, (topa + topb)/bottom -def interval_to_center_radius((low, high)): - return (high+low)/2, (high-low)/2 + +def binomial_conf_center_radius(x, n, conf=0.95): + p = x/n + left, right = binomial_conf_interval(x, n, conf) + return p, max(p - left, right - p) def reversed(x): try: