def boxcar(y, window_size=3):
"""
Smooth the input vector using the mean of the neighboring values,
where neighborhood size is defined by the window.
Parameters
==========
y : array
The vector to be smoothed.
window_size : int
An odd integer describing the window size.
Returns
=======
: array
The smoothed array.
"""
filt = np.ones(window_size) / window_size
return Series(np.convolve(y, filt, mode='same'), index=y.index)
评论列表
文章目录