0
$\begingroup$

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

$\endgroup$
  • $\begingroup$ This question does not concern mathematics and would be better suited for TeX - LaTeX Stackexchange. $\endgroup$ – Brian Mar 28 at 1:08
  • $\begingroup$ I tried there first and was suggested to ask here instead. $\endgroup$ – Ocean Scientist Mar 28 at 1:14
  • 1
    $\begingroup$ I don't understand the question $\endgroup$ – Jorge Fernández Hidalgo Mar 28 at 1:14
  • $\begingroup$ You can write median bias = median a - median b $\endgroup$ – Jorge Fernández Hidalgo Mar 28 at 1:15
  • 1
    $\begingroup$ The formula only, I can convert it into Tex myself. $\endgroup$ – Ocean Scientist Mar 28 at 1:18
0
$\begingroup$

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,

The notation $\text{median}(S)$ represents the median of the set $S$,

followed at some later time by an expression such as

$$ \text{median} \{a_i - b_i \mid 1 \leq i \leq n\}. $$

$\endgroup$
  • $\begingroup$ So there isn't a nice way of doing it. Interesting. I agree that the first one does the job, but it's a bit much! I think I will just define that median means median like your suggestion 2. Thanks very much! $\endgroup$ – Ocean Scientist Mar 28 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.