def statisticalInefficiency_fft(A_n, mintime=3, memsafe=None):
    """Compute the (cross) statistical inefficiency of (two) timeseries.

    Parameters
    ----------
    A_n : np.ndarray, float
        A_n[n] is nth value of timeseries A.  Length is deduced from vector.
    mintime : int, optional, default=3
        minimum amount of correlation function to compute (default: 3)
        The algorithm terminates after computing the correlation time out to mintime when the
        correlation function first goes negative.  Note that this time may need to be increased
        if there is a strong initial negative peak in the correlation function.
    memsafe: bool, optional, default=None (in depreciation)
        If this function is used several times on arrays of comparable size then one might benefit 
        from setting this option to False. If set to True then clear np.fft cache to avoid a fast 
        increase in memory consumption when this function is called on many arrays of different sizes.

    Returns
    -------
    g : np.ndarray,
        g is the estimated statistical inefficiency (equal to 1 + 2 tau, where tau is the correlation time).
        We enforce g >= 1.0.

    Notes
    -----
    The same timeseries can be used for both A_n and B_n to get the autocorrelation statistical inefficiency.
    The fast method described in Ref [1] is used to compute g.

    References
    ----------
    [1] J. D. Chodera, W. C. Swope, J. W. Pitera, C. Seok, and K. A. Dill. Use of the weighted
        histogram analysis method for the analysis of simulated and parallel tempering simulations.
        JCTC 3(1):26-41, 2007.

    """
    try:
        import statsmodels.api as sm
    except ImportError as err:
        err.args = (err.args[0] + "\n You need to install statsmodels to use the FFT based correlation function.",)
        raise

    # Create np copies of input arguments.
    A_n = np.array(A_n)

    # Get the length of the timeseries.
    N = A_n.size

    C_t = sm.tsa.stattools.acf(A_n, fft=True, unbiased=True, nlags=N)
    t_grid = np.arange(N).astype('float')
    g_t = 2.0 * C_t * (1.0 - t_grid / float(N))

    """
    LNN Note:
    Numpy 1.12 fft.fftpack swiched from using a Python dict for the cache to a LRU cache which auto prunes.
    This makes the .clear() method undefined since the LRU does not have such a method.

    Since the LRU *should* remove the problems which this code resolved (GH issue #168), I am removing this code from
    execution. However, there may still be a problem with the LRU cache so I am leaving the code in case we need to
    further test it
    """
    #make function memory safe by clearing np.fft cache
    #this assumes that statsmodels uses np.fft
    #if memsafe:
    #    np.fft.fftpack._fft_cache.clear()
    #    np.fft.fftpack._real_fft_cache.clear()
    if memsafe is not None:
        warnings.warn("NumPy's FFT pack now uses an LRU cache to fix the very problem that the memsafe keyword "
                      "was protecting. This argument no longer changes the code and will be removed in a future "
                      "version.", FutureWarning)
    
    try:
        ind = np.where((C_t <= 0) & (t_grid > mintime))[0][0]
    except IndexError:
        ind = N

    g = 1.0 + g_t[1:ind].sum()
    g = max(1.0, g)

    return g
Compute the (cross) statistical inefficiency of (two) timeseries.

    Parameters
    ----------
    A_n : np.ndarray, float
        A_n[n] is nth value of timeseries A.  Length is deduced from vector.
    mintime : int, optional, default=3
        minimum amount of correlation function to compute (default: 3)
        The algorithm terminates after computing the correlation time out to mintime when the
        correlation function first goes negative.  Note that this time may need to be increased
        if there is a strong initial negative peak in the correlation function.
    memsafe: bool, optional, default=None (in depreciation)
        If this function is used several times on arrays of comparable size then one might benefit 
        from setting this option to False. If set to True then clear np.fft cache to avoid a fast 
        increase in memory consumption when this function is called on many arrays of different sizes.

    Returns
    -------
    g : np.ndarray,
        g is the estimated statistical inefficiency (equal to 1 + 2 tau, where tau is the correlation time).
        We enforce g >= 1.0.

    Notes
    -----
    The same timeseries can be used for both A_n and B_n to get the autocorrelation statistical inefficiency.
    The fast method described in Ref [1] is used to compute g.

    References
    ----------
    [1] J. D. Chodera, W. C. Swope, J. W. Pitera, C. Seok, and K. A. Dill. Use of the weighted
        histogram analysis method for the analysis of simulated and parallel tempering simulations.
        JCTC 3(1):26-41, 2007.