def test_moving_average(self):
     """
     Should return the moving average of data.
     """
     a = [2, 2, 4, 4]
     m0 =  [ 2.,  2.,  3.,  4.]
     m1 = amplitudes.moving_average(a, 2)
     for i in range(0, len(m0)):
         self.assertEqual(m0[i], m1[i])
Exemple #2
0
def _agc_instantaneous(data, window_size, desired_rms):
    """
    Computes the instantaneous-amplitude AGC for data.

    :param data: ``list`` of data values to compute rms for.
    :param window_size: Length of window in number of samples.
    :param desired_rms: Root-mean-squared value of
        ``data * _agc_instantaneous(data)``.
    :return: ``numpy.nparray`` with ``len(data)`` AGC values
    """
    return float(desired_rms) / moving_average(np.abs(data), window_size)