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
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: