def movavg(x, n):
 w = np.empty((n,), dtype=float)
 w[:] = (1.0 / n)
 return np.convolve(x, w, mode=u'valid')

def movavg ( x , n ) : w = np . empty ( ( n , ) , dtype = float ) w [ : ] = ( 1.0 / n ) return np . convolve ( x , w , mode = u'valid' )
compute the len moving average of *x* .