discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Moving Average Block


From: West, Nathan
Subject: Re: [Discuss-gnuradio] Moving Average Block
Date: Thu, 7 Jan 2016 14:32:04 -0500

Chiming in that this is also a great opportunity to contribute improved documentation after you've figured out your answer.

In addition to Marcus' comment, looking at the code helps (and in this case is pretty easy):

       set_history(d_length);
      // skipping some stuff
      @I_TYPE@ sum = 0;
      int num_iter = (noutput_items>d_max_iter) ? d_max_iter : noutput_items;
      for(int i = 0; i < d_length-1; i++) {
        sum += in[i];
      }

      for(int i = 0; i < num_iter; i++) {
        sum += in[i+d_length-1];
        out[i] = sum * d_scale;
        sum -= in[i];
      }

The first loop builds up an "initial" sum, the second loop does the grunt work of generating output samples. You'll always get the sum of the last n_length samples scaled by some factor (n_length for arithmetic mean).



On Thu, Jan 7, 2016 at 1:23 PM, Pedro Gabriel Adami <address@hidden> wrote:
Dear all,

The documentation of the Moving Average block made me feel confuse about its functionality. It says: "output is the moving sum of the last N samples". If I need a sum of 100 samples, this block will sum the 100 samples that I need and after that it will get another different samples? For example: 1+2+3+...+100 and 101+102+...200. Or it will do this: 1+2+...+100 and 2+3+...+101 and 3+4+...+102.

I know it seems a little confuse, but I didn't find a better way to explain this, sorry.

Thanks in advance.

--
Atenciosamente,
Pedro Gabriel Adami
Graduando do 5º período de Engenharia de Controle e Automação no Instituto Nacional de Telecomunicações - Inatel

_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio



reply via email to

[Prev in Thread] Current Thread [Next in Thread]