I have some code to calculate the mean bias between two arrays.
$$mean_{bias}=\frac{\sum_{i=1}^{n}a_i-b_i}{n}$$
and was hoping to represent the median instead:
$$median_{bias}=Median(a-b)$$
Does something like this hold true? But it's not sorted so index will not be the middle:
$$median_{bias}=\sum_{i=n/2}^{n/2+1}a_i-b_i$$
How can I represent this?
Thanks
You might be able to write something like this:
\begin{gather} bias_{\text{median}} = \frac12\left(\max_i\left\{a_i-b_i \mid \left\lvert\left\{j\mid a_i-b_i > a_j-b_j\right\}\right\rvert < \tfrac n2\right\} \\ \qquad\qquad\qquad\qquad\qquad + \min_i\left\{a_i-b_i \mid \left\lvert\left\{j\mid a_i-b_i < a_j-b_j\right\}\right\rvert < \tfrac n2\right\} \right) \end{gather}
This is a way of saying that if $n$ is odd, you take the value $a_i - b_i$ that partitions the list of values $a_j - b_j$ (excluding $a_i - b_i$ itself) into two equal sets, one of values less than $a_i - b_i$ and one of values greater; and if $n$ is even you take the mean of the two values $a_i - b_i$ and $a_{i'} - b_{i'}$ that partition the list of values $a_j - b_j$ (excluding those two values) into two equal sets.
But I think this is a rather horrible expression.
A better way is probably to define some notation of your own, for example,
followed at some later time by an expression such as
$$ \text{median} \{a_i - b_i \mid 1 \leq i \leq n\}. $$