I'm searching for a computationally efficient algorithm to calculate the sliding mean deviation from sample $x_a$ to sample $x_b$ belonging to a large set $x_0, x_1 ... x_n$ with the condition that $a$ and $b$ are incremented by 1 at every iteration and the window size $a-b$ is constant:
$$\frac{1}{a-b+1} \sum_{i = a}^{b}{|x_i - \bar x_{ab}|} $$
Reiterating the above formula across every window $a,b$ (with $a-b$ constant) in my data set is slow due to the amount of samples and the large window size. I suspect a better method could be used which takes advantage of the already-computed values from the previous window.
R
(to compute the running absolute deviation around medians) and found it to be too slow to be practicable. If there is any performance to be gained, it will be for an online algorithm (where $n$ constantly grows) and $b-a$ is huge. $\endgroup$ – whuber♦ Apr 9 '17 at 16:22