import math


def _kt_estim_update(new_bit, counts):
    """Computes log(P(Next_bit=new_bit|counts))
    for the the Krichevski-Trofimov estimator.
    """
    return math.log((counts[new_bit] + 0.5) / float((sum(counts) + 1)))