def smooth(x, window_len=<NUM_LIT:10>, window='<STR_LIT>'):
<EOL>if x.ndim != <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if x.size < window_len:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if window_len < <NUM_LIT:3>:<EOL><INDENT>return x<EOL><DEDENT>if not window in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>s = numpy.r_[<NUM_LIT:2> * x[<NUM_LIT:0>] - x[window_len:<NUM_LIT:1>:-<NUM_LIT:1>],<EOL>x, <NUM_LIT:2> * x[-<NUM_LIT:1>] - x[-<NUM_LIT:1>:-window_len:-<NUM_LIT:1>]]<EOL>if window == '<STR_LIT>':  <EOL><INDENT>w = numpy.ones(window_len, '<STR_LIT:d>')<EOL><DEDENT>else:<EOL><INDENT>w = getattr(numpy, window)(window_len)<EOL><DEDENT>y = numpy.convolve(w / w.sum(), s, mode='<STR_LIT>')<EOL>return y[window_len - <NUM_LIT:1>:-window_len + <NUM_LIT:1>]<EOL>
Smooth the data using a window with requested size.

This method is based on the convolution of a scaled window with the signal.
The signal is prepared by introducing reflected copies of the signal
(with the window size) in both ends so that transient parts are minimized
in the begining and end part of the output signal.

Parameters
----------
x : numpy.array
    the input signal
window_len : int
    the dimension of the smoothing window
window : str
    the type of window from 'flat', 'hanning', 'hamming', 'bartlett', 'blackman'
    flat window will produce a moving average smoothing.

Returns
-------
The smoothed signal

See Also
-------

numpy.hanning, numpy.hamming, numpy.bartlett, numpy.blackman, numpy.convolve
scipy.signal.lfilter

Examples
--------

>>> import numpy as np
>>> from timeside.plugins.grapher.utils import smooth
>>> t = np.arange(-2,2,0.1)
>>> x = np.sin(t)+np.random.randn(len(t))*0.1
>>> y = smooth(x)
>>> import matplotlib.pyplot as plt
>>> plt.plot(x) # doctest: +SKIP
[<matplotlib.lines.Line2D object at 0x...>]
>>> plt.plot(y) # doctest: +SKIP
[<matplotlib.lines.Line2D object at 0x...>]
>>> plt.legend(['Source signal', 'Smoothed signal']) # doctest: +SKIP
<matplotlib.legend.Legend object at 0x...>
>>> plt.show() # doctest: +SKIP