(nfinite, minp, result)
return res
Get result kurt taking into account min periods.
Get result kurt taking into account min periods.
Get result kurt taking into account min periods .
def kurt_result_or_nan(nfinite, minp, result):
    """Get result kurt taking into account min periods."""
    if nfinite < max(4, minp):
        return numpy.nan

    _sum, square_sum, cube_sum, fourth_degree_sum = result

    n = nfinite
    m2 = (square_sum - _sum * _sum / n) / n
    m4 = (fourth_degree_sum - 4*_sum*cube_sum/n + 6*_sum*_sum*square_sum/n/n - 3*_sum*_sum*_sum*_sum/n/n/n) / n
    res = 0 if m2 == 0 else m4 / m2 ** 2.0

    if (n > 2) & (m2 > 0):
        res = 1.0/(n-2)/(n-3) * ((n**2-1.0)*m4/m2**2.0 - 3*(n-1)**2.0)

    return res
def kurt_result_or_nan ( nfinite , minp , result ) : if nfinite < max ( 4 , minp ) : return numpy . nan _sum , square_sum , cube_sum , fourth_degree_sum = result n = nfinite m2 = ( square_sum - _sum * _sum / n ) / n m4 = ( fourth_degree_sum - 4 * _sum * cube_sum / n + 6 * _sum * _sum * square_sum / n / n - 3 * _sum * _sum * _sum * _sum / n / n / n ) / n res = 0 if m2 == 0 else m4 / m2 ** 2.0 if ( n > 2 ) & ( m2 > 0 ) : res = 1.0 / ( n - 2 ) / ( n - 3 ) * ( ( n ** 2 - 1.0 ) * m4 / m2 ** 2.0 - 3 * ( n - 1 ) ** 2.0 ) return res