def diffa(dist, alpha, r):
    """
        Compute the derivative of local-local BDeu score.
    """

    res = 0.0
    for n in dist:
        for i in range(n):
            res += 1.0/(i*r+alpha)
    for i in range(sum(dist)):
        res -= 1.0/(i+alpha)
    return res