Login Page - Create Account

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 \(\{\tilde{X}_{t-n+1},\tilde{X}_{t-n},...,\tilde{X}_t\}\) be a permutation of these values such that \(\tilde{X}_{t-n+1} \leq \tilde{X}_{t-n} \leq \cdot\cdot\cdot \leq \tilde{X}_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} \tilde{X}_{t - \left\lfloor{0.5(t + 1)}\right\rfloor} & t + 1 \space odd \\ \left. \left(\tilde{X}_{t-0.5(t + 1)} + \tilde{X}_{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} \tilde{X}_{t - \left\lfloor{0.5n}\right\rfloor} & n \space odd \\ \left. \left(\tilde{X}_{t-0.5n} + \tilde{X}_{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.



The spreadsheet below contains the formulas for this study in Spreadsheet format. Save this Spreadsheet to the Data Files Folder.

Open it through File >> Open Spreadsheet.


*Last modified Wednesday, 28th September, 2022.