

def smooth(x, window_len=7, window='hanning'):
    "\n    Smooth the data in x using convolution with a window of requested\n    size and type.\n\n    Parameters\n    ----------\n    x : array_like(float)\n        A flat NumPy array containing the data to smooth\n    window_len : scalar(int), optional\n        An odd integer giving the length of the window.  Defaults to 7.\n    window : string\n        A string giving the window type. Possible values are 'flat',\n        'hanning', 'hamming', 'bartlett' or 'blackman'\n\n    Returns\n    -------\n    array_like(float)\n        The smoothed values\n\n    Notes\n    -----\n    Application of the smoothing window at the top and bottom of x is\n    done by reflecting x around these points to extend it sufficiently\n    in each direction.\n\n    "
    if (len(k) < window_len):
        raise ValueError('Input vector length must be >= window length.')
    if (window_len < 3):
        raise ValueError('Window length must be at least 3.')
    if (not (window_len % 2)):
        window_len += 1
        print('Window length reset to {}'.format(window_len))
    windows = {
        'hanning': np.hanning,
        'hamming': np.hamming,
        'bartlett': np.bartlett,
        'blackman': np.blackman,
        'flat': np.ones,
    }
    k = int((window_len / 2))
    xb = x[:k]
    xt = x[(- k):]
    s = np.concatenate((xb[::(- 1)], x, xt[::(- 1)]))
    if (window in windows.keys()):
        w = windows[window](window_len)
    else:
        msg = "Unrecognized window type '{}'".format(window)
        print((msg + ' Defaulting to hanning'))
        w = windows['hanning'](window_len)
    return np.convolve((w / w.sum()), s, mode='valid')

dataset/ETHPy150Open QuantEcon/QuantEcon.py/quantecon/estspec.py smooth/VarMisuse@24/311 `x`->`k`