def iat(x, maxlag=None):
    """Calculate the integrated autocorrelation time (IAT), given the trace from a Stochastic."""

    if not maxlag:
        # Calculate maximum lag to which autocorrelation is calculated
        maxlag = _find_max_lag(x)

    acr = [autocorr(x, lag) for lag in range(1, maxlag + 1)]

    # Calculate gamma values
    gammas = [(acr[2 * i] + acr[2 * i + 1]) for i in range(maxlag // 2)]

    cut = _cut_time(gammas)

    if cut + 1 == len(gammas):
        print_("Not enough lag to calculate IAT")

    return np.sum(2 * gammas[:cut + 1]) - 1.0
def iat ( x , maxlag = None ) : if not maxlag : maxlag = _find_max_lag ( x ) acr = [ autocorr ( x , lag ) for lag in range ( 1 , maxlag + 1 ) ] gammas = [ ( acr [ 2 * i ] + acr [ 2 * i + 1 ] ) for i in range ( maxlag // 2 ) ] cut = _cut_time ( gammas ) if cut + 1 == len ( gammas ) : print_ ( "Not enough lag to calculate IAT" ) return np . sum ( 2 * gammas [ : cut + 1 ] ) - 1.0
Calculate the integrated autocorrelation time (IAT), given the trace from a Stochastic.