def pacf_yw(x, nlags=40, method='unbiased'):
    "Partial autocorrelation estimated with non-recursive yule_walker\n\n    Parameters\n    ----------\n    x : 1d array\n        observations of time series for which pacf is calculated\n    nlags : int\n        largest lag for which pacf is returned\n    method : 'unbiased' (default) or 'mle'\n        method for the autocovariance calculations in yule walker\n\n    Returns\n    -------\n    pacf : 1d array\n        partial autocorrelations, maxlag+1 elements\n\n    Notes\n    -----\n    This solves yule_walker for each desired lag and contains\n    currently duplicate calculations.\n    "
    pacf = [1.0]
    for k in range(1, (nlags + 1)):
        pacf.append(yule_walker(x, k, method=method)[0][(- 1)])
    return np.array(pacf)
Partial autocorrelation estimated with non-recursive yule_walker

Parameters
----------
x : 1d array
    observations of time series for which pacf is calculated
nlags : int
    largest lag for which pacf is returned
method : 'unbiased' (default) or 'mle'
    method for the autocovariance calculations in yule walker

Returns
-------
pacf : 1d array
    partial autocorrelations, maxlag+1 elements

Notes
-----
This solves yule_walker for each desired lag and contains
currently duplicate calculations.
def pacf_yw(x, nlags=40, method='unbiased'):
    "Partial autocorrelation estimated with non-recursive yule_walker\n\n    Parameters\n    ----------\n    x : 1d array\n        observations of time series for which pacf is calculated\n    nlags : int\n        largest lag for which pacf is returned\n    method : 'unbiased' (default) or 'mle'\n        method for the autocovariance calculations in yule walker\n\n    Returns\n    -------\n    pacf : 1d array\n        partial autocorrelations, maxlag+1 elements\n\n    Notes\n    -----\n    This solves yule_walker for each desired lag and contains\n    currently duplicate calculations.\n    "
    pacf = [1.0]
    for k in range(1, (nlags + 1)):
        pacf.append(yule_walker(x, k, method=method)[0][(- 1)])
    return np.array(pacf)