Let's say I have an array of $N$ numbers:
$n_1, n_2, .... n_N$
I then calculate a running average of those numbers, by averaging $A$ numbers at a time, which will result in the following array:
$a_1, a_2, .... a_{N-A+1}$ , where
$a_1 = \frac {n_1 + n_2 + ... + n_A}{A}$
$a_2 = \frac {n_2 + n_3 + ... + n_{A+1}}{A}$
...
I then calculate a running average of the running average I obtained above, by averaging B numbers at a time, which will result in the following array:
$b_1, b_2, .... b_{N-A-B+2}$ , where
$b_1 = \frac {a_1 + a_2 + ... + a_B}{B}$
$b_2 = \frac {a_2 + a_3 + ... + a_{B+1}}{B}$
...
My question is, is there some general formula that can get you the second running average (b numbers) directly from original set (n numbers), with arbitrary A and B coefficients?
I'm asking, because I did a few of these by hand, and the results look very much like digital filters (weighted averages). Thanks.
For $A=3,B=4$, if we just substitute in we get $b_i=\frac {a_i+a_{i+1}+a_{i+2}+a_{i+3}}4=\frac{n_i+2n_{i+1}+3n_{i+2}+3n_{i+3}+2n_{i+4}+n_{i+5}}{12}$ The pattern should be suggestive. You ramp up the coefficients, stay constant at the peak, then ramp them down. You could write it with summation signs if you want. $$b_i=\frac 1B\sum_{j=i}^{i+B-1}a_j=\frac 1{AB}\sum_{j=i}^{i+B-1}\sum_{k=j}^{j+A-1}n_k$$ and you would like to write this as $$b_i=\frac 1{AB}\sum_{j=i}^{i+A+B-2}c_jn_n$$ The $c_j$ are the coefficients $1,2,3,3,2,1$ above. You can write $c_j=\min(A,B)-$end effects, where the end effects cause the ramp down at the ends. If $j-i \lt \min(A,B), c_j=j-i+1$ and if $i+A+B-2-j \lt \min (A,B), c_j=i+A+B-1-j$