def _tie_correct(sample):
    """
    Returns the tie correction value for U.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.tiecorrect.html

    """
    tc = 0
    n = sum(sample.values())

    if n < 2:
        return 1.0  # Avoid a ``ZeroDivisionError``.

    for k in sorted(sample.keys()):
        tc += math.pow(sample[k], 3) - sample[k]
    tc = 1 - tc / (math.pow(n, 3) - n)

    return tc
def _tie_correct ( sample ) : tc = 0 n = sum ( sample . values ( ) ) if n < 2 : return 1.0 for k in sorted ( sample . keys ( ) ) : tc += math . pow ( sample [ k ] , 3 ) - sample [ k ] tc = 1 - tc / ( math . pow ( n , 3 ) - n ) return tc
Returns the tie correction value for U.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.tiecorrect.html