def moving_average(a, n=3):
    ' \n    perform moving average, return a vector of same length as input\n\n    NOTE: also in kalman.filters\n    '
    a = a.ravel()
    a = np.concatenate((([a[0]] * (n - 1)), a))
    ret = np.cumsum(a, dtype=float)
    ret[n:] = (ret[n:] - ret[:(- n)])
    ret = (ret[(n - 1):] / n)
    return ret
perform moving average, return a vector of same length as input

NOTE: also in kalman.filters
def moving_average(a, n=3):
    ' \n    perform moving average, return a vector of same length as input\n\n    NOTE: also in kalman.filters\n    '
    a = a.ravel()
    a = np.concatenate((([a[0]] * (n - 1)), a))
    ret = np.cumsum(a, dtype=float)
    ret[n:] = (ret[n:] - ret[:(- n)])
    ret = (ret[(n - 1):] / n)
    return ret