def autocorr(s, axis=(-1)):
 N = s.shape[axis]
 S = np.fft.fft(s, n=((2 * N) - 1), axis=axis)
 sxx = np.fft.ifft((S * S.conjugate()), axis=axis).real[:N]
 return (sxx / N)

def autocorr ( s , axis = ( - 1 ) ) : N = s . shape [ axis ] S = np . fft . fft ( s , n = ( ( 2 * N ) - 1 ) , axis = axis ) sxx = np . fft . ifft ( ( S * S . conjugate ( ) ) , axis = axis ) . real [ : N ] return ( sxx / N )
returns the autocorrelation of signal s at all lags .