Movavg-func
This function returns the moving average of adjacent ranges [i-nb, i+nf], for a point i. The part of range beyond the input vector is dropped.
The adjacent average at point i with iback backward offset and iforw forward offset is:
vector movavg(vector vx, int back, int forward)
vx
back
forward
Return the adjacent average vector.
// Col(2) will be filled with adjacent value at each point. Note that // col(2)[9] = (col(1)[9]+col(1)[10])/2 and col(1)[10] = col(2)[10] for(ii=1;ii<=10;ii++) col(1)[ii] = ii; col(2)=movavg(col(1),0, 2);
// The subrange [10:20] in col(2) will be filled with adjacent average // of the given subrange [10:20] in col(1). range aa=col(1)[10:20]; range bb=col(2)[10:20]; bb = movavg(aa, 3, 3);