let wilcoxon_rank_sum_to_z arr1 arr2 =
let l1,l2 = (Array.length arr1),(Array.length arr2) in
let ranked = rank (Array.append arr1 arr2) in
let arr1 = Array.sub ranked 0 l1 in
let l1,l2 = (Float.of_int l1), (Float.of_int l2) in
let sum1 =
let f acc elem = elem +. acc in
Array.fold ~f ~init:0. arr1
in
let expectation = (l1 *. (l1 +. l2 +. 1.)) /. 2. in
let var = (l1 *. l2 *. ((l1 +. l2 +. 1.) /. 12.)) in
(sum1 -. expectation) /. (sqrt var)