def moving_avg(v, N):
    """
    simple moving average.

    Parameters
    ----------
    v : list
        data ta to average
    N : integer
        number of samples per average.

    Returns
    -------
    m_avg : list
        averaged data.
    """
    s, m_avg = [0], []
    for i, x in enumerate(v, 1):
        s.append(s[i - 1] + x)
        if i >= N:
            avg = (s[i] - s[i - N]) / N
            m_avg.append(avg)
    return m_avg