def similarity(bitset1, bitset2, number_of_bits, corr_st, corr_sto):
    """Calculate modified Tanimoto similarity between two fingerprints

    Given two fingerprints of length n with a and b bits set in each fingerprint,
    respectively, and c bits set in both fingerprint,
    selected from a data set of fingerprint with a mean bit density of ρ\ :sub:`0`,
    the modified Tanimoto similarity S\ :sub:`MT` is calculated as

    .. math::

        S_{MT} = (\\frac{2 - ρ_0}{3}) S_T + (\\frac{1 + ρ_0}{3}) S_{T0}

    where ST is the standard Tanimoto coefficient

    .. math::

        S_T = \\frac{c}{a + b - c}

    and Sr0 is the inverted Tanimoto coefficient

    .. math::

        S_{T0} = \\frac{n - a - b + c}{n -c}

    Args:
        bitset1 (pyroaring.BitMap): First fingerprint
        bitset2 (pyroaring.BitMap): Second fingerprint
        number_of_bits (int): Number of bits for all fingerprints
        corr_st (float): St correction
        corr_sto (float): Sto correction

    Returns:
        float: modified Tanimoto similarity
    """
    a = len(bitset1)
    b = len(bitset2)
    c = bitset1.intersection_cardinality(bitset2)
    n = number_of_bits
    st = float(c) / (a + b - c)
    st0 = (n - a - b + c) / float(n - c)
    smt = corr_st * st + corr_sto * st0
    return smt