Mathematica
For window size \(k=2\)
v = {1, 2, 3, 4, 5, 6, 7, 8};
f = {1/2, 1/2};
ListConvolve[f, v] // N
|
{1.5,2.5,3.5,4.5,5.5,6.5,7.5}
|
For window size \(k=3\)
v = {1, 2, 3, 4, 5, 6, 7, 8};
f = Table[1/3, {3}];
ListConvolve[f, v] // N
|
{2., 3., 4., 5., 6., 7.}
|