finding value of X that equates two proportions of true inequalities Given two sets of numbers of different lengths, how would one find the value of X such that the proportion of numbers in the first set greater than X equates the proportion of numbers in the second set smaller than X?
 A: Order the two sets separately in ascending numbers. Say the first ordered set is now {$a_i$}, containing $A$ numbers, and the second one {$b_i$}, containing $B$ numbers. Then, if I understand the question correctly, you are asking for two proportions, given some number $X$, with the following condition:
$$
\qquad \frac{1}{A} \sum_{a_i > X} 1 -  \frac{1}{B} \sum_{X > b_i} 1  = 0
$$
First observation: you won't always reach equality, since the first and the second term are two fractions with different denominator, which cannot necessarily be made equal.
So a better criterion is given below.
A way to proceed would be the following:
Unite the sets {$a_i$} and  {$b_i$} into a new set and order this set in ascending order, giving {$c_i$}.
Define a set {$x_i$} with $x_1 = c_1 - \epsilon$, for $1 < i \le A+B$: $x_i = \frac12 (c_i + c_{i-1})$, and lastly,  $x_{A+B+1} = c_{A+B} + \epsilon$, where $\epsilon$ is a small positive number. This set will have $A+B+1$ elements.
Then do the following:
initialize $k = 1; X = x_k$.
while $\frac{1}{A} \sum_{a_i > X} 1 -  \frac{1}{B} \sum_{X > b_i} 1  > 0 $
$\qquad k = k+1; X = x_k$
end
Once this is processed, the last assignment of $X$ is the $X$ you are looking for.
The way this works is the following:
For $k=1$, you have   $\frac{1}{A} \sum_{a_i > X} 1 -  \frac{1}{B} \sum_{X > b_i} 1  =1$.
For every transition from $x_k$ to $x_{k+1}$, either one of the two sums will change: either the first sum ($a_i$) looses one element, or the second  ($b_i$) gains one element. So the stop criterion is not exactly matched when the difference equals zero, but when it changes sign. This works for all sizes $A$ and $B$.
The stop criterion will always be reached, since for $k=A+B+1$, you have   $\frac{1}{A} \sum_{a_i > X} 1 -  \frac{1}{B} \sum_{X > b_i} 1  =-1$.
