def compute_q_noisy_max_approx(counts, noise_eps):
 winner = np.argmax(counts)
 counts_normalized = (noise_eps * (counts - counts[winner]))
 counts_rest = np.array([counts_normalized[i] for i in xrange(len(counts)) if (i != winner)])
 gap = (- max(counts_rest))
 q = (((len(counts) - 1) * (gap + 2.0)) / (4.0 * math.exp(gap)))
 return min(q, (1.0 - (1.0 / len(counts))))

def compute_q_noisy_max_approx ( counts , noise_eps ) : winner = np . argmax ( counts ) counts_normalized = ( noise_eps * ( counts - counts [ winner ] ) ) counts_rest = np . array ( [ counts_normalized [ i ] for i in xrange ( len ( counts ) ) if ( i != winner ) ] ) gap = ( - max ( counts_rest ) ) q = ( ( ( len ( counts ) - 1 ) * ( gap + 2.0 ) ) / ( 4.0 * math . exp ( gap ) ) ) return min ( q , ( 1.0 - ( 1.0 / len ( counts ) ) ) )
returns ~ pr[outcome != winner] .