def _sigma_est_kpss(resids, nobs, lags):
 s_hat = sum((resids ** 2))
 for i in range(1, (lags + 1)):
  resids_prod = np.dot(resids[i:], resids[:(nobs - i)])
  s_hat += ((2 * resids_prod) * (1.0 - (i / (lags + 1.0))))
 return (s_hat / nobs)

def _sigma_est_kpss ( resids , nobs , lags ) : s_hat = sum ( ( resids ** 2 ) ) for i in range ( 1 , ( lags + 1 ) ) : resids_prod = np . dot ( resids [ i : ] , resids [ : ( nobs - i ) ] ) s_hat += ( ( 2 * resids_prod ) * ( 1.0 - ( i / ( lags + 1.0 ) ) ) ) return ( s_hat / nobs )
computes equation 10 .