datasketch/b_bit_minhash.py
def _calc_c(self, a1, a2, r1, r2):
        '''
        Compute the functions C1 and C2
        '''
        if r1 == 0.0 and r2 == 0.0:
            # Find the limits of C1 and C2 as r1 -> 0 and r2 -> 0
            # Since the b-value must be the same and r1 = r2,
            # we have A1(r1, b1) = A2(r2, b2) = A,
            # then the limits for both C1 and C2 are A.
            return a1, a2
        div = 1 / (r1 + r2)
        c1 = (a1 * r2 + a2 * r1) * div
        c2 = (a1 * r1 + a2 * r2) * div
        return c1, c2
def _calc_c(self, a1, a2, r1, r2):
        '''
        Compute the functions C1 and C2
        '''
        if r1 == 0.0 and r2 == 0.0:
            # Find the limits of C1 and C2 as r1 -> 0 and r2 -> 0
            # Since the b-value must be the same and r1 = r2,
            # we have A1(r1, b1) = A2(r2, b2) = A,
            # then the limits for both C1 and C2 are A.
            return a1, a2
        div = 1 / (r1 + r2)
        c1 = (a1 * r2 + a2 * r1) * div
        c2 = (a1 * r1 + a2 * r2) * div
        return c1, c2
Compute the functions C1 and C2