let mad a = assert (Array.length a > 0); let med = median a in let a = Array.map (fun v -> Float.abs (v -. med)) a in median a