# Technical Studies Reference

### Moving Median

This study calculates and displays a Moving Median of the data specified by the Input Data Input.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_i$$ be the value of the Input Data at Index $$i$$. Let the Input Length be denoted as $$n$$. At Index $$t$$, the set of values of $$X$$ that are considered is $$\{X_{t-n+1},X_{t-n},...,X_t\}$$. Let $$\{Y_{t-n+1},Y_{t-n},...,Y_t\}$$ be a permutation of these values such that $$Y_{t-n+1} \leq Y_{t-n} \leq \cdot\cdot\cdot \leq Y_t$$. Then we denote the Moving Median at Index $$t$$ for the given Inputs as $$MMed_t(X,n)$$, and we compute it for $$t \geq 0$$ as follows.

For $$0 \leq t < n - 1$$:

$$\displaystyle{MMed_t(X,n) = \left\{ \begin{matrix} Y_{t - \left\lfloor{0.5(t + 1)}\right\rfloor} & t + 1 \space odd \\ \left. \left(Y_{t-0.5(t + 1)} + Y_{t - 0.5(t + 1) + 1}\right) \middle/ 2\right. & t + 1 \space even \end{matrix}\right .}$$

For $$t \geq n - 1$$:

$$\displaystyle{MMed_t(X,n) = \left\{ \begin{matrix} Y_{t - \left\lfloor{0.5n}\right\rfloor} & n \space odd \\ \left. \left(Y_{t-0.5n} + Y_{t - 0.5n + 1}\right) \middle/ 2\right. & n \space even \end{matrix}\right .}$$

For an explanation of the floor function ($$\left\lfloor{\space\space}\right\rfloor$$), refer to our description here.