let pseudomedian a =
let n = Array.length a in
assert (n > 0);
if n = 1 then
a.(0)
else
let nn = n*(n-1)/2 in
let averages = Array.create nn 0.0 in
let idx = ref 0 in
for i = 0 to n-2 do
for j = i+1 to n-1 do
averages.(!idx) <- (a.(i) +. a.(j)) /. 2.0;
incr idx
done
done;
median averages