(data, c=None)
return (T, total)
Return sum of square deviations of sequence data.

    If ``c`` is None, the mean is calculated in one pass, and the deviations
    from the mean are calculated in a second pass. Otherwise, deviations are
    calculated from ``c`` as given. Use the second case with care, as it can
    lead to garbage results.
Return sum of square deviations of sequence data.
Return sum of square deviations of sequence data .
def _ss(data, c=None):
    """Return sum of square deviations of sequence data.

    If ``c`` is None, the mean is calculated in one pass, and the deviations
    from the mean are calculated in a second pass. Otherwise, deviations are
    calculated from ``c`` as given. Use the second case with care, as it can
    lead to garbage results.
    """
    if c is not None:
        T, total, count = _sum((x-c)**2 for x in data)
        return (T, total)
    T, total, count = _sum(data)
    mean_n, mean_d = (total / count).as_integer_ratio()
    partials = Counter()
    for n, d in map(_exact_ratio, data):
        diff_n = n * mean_d - d * mean_n
        diff_d = d * mean_d
        partials[diff_d * diff_d] += diff_n * diff_n
    if None in partials:
        # The sum will be a NAN or INF. We can ignore all the finite
        # partials, and just look at this special one.
        total = partials[None]
        assert not _isfinite(total)
    else:
        total = sum(Fraction(n, d) for d, n in partials.items())
    return (T, total)
def _ss ( data , c = None ) : if c is not None : T , total , count = _sum ( ( x - c ) ** 2 for x in data ) return ( T , total ) T , total , count = _sum ( data ) mean_n , mean_d = ( total / count ) . as_integer_ratio ( ) partials = Counter ( ) for n , d in map ( _exact_ratio , data ) : diff_n = n * mean_d - d * mean_n diff_d = d * mean_d partials [ diff_d * diff_d ] += diff_n * diff_n if None in partials : # The sum will be a NAN or INF. We can ignore all the finite # partials, and just look at this special one. total = partials [ None ] assert not _isfinite ( total ) else : total = sum ( Fraction ( n , d ) for d , n in partials . items ( ) ) return ( T , total )