let variance a = let n = Array.length a in assert (n > 1); let avrg = mean a in let f v = let diff = v -. avrg in diff *. diff in let a = Array.map f a in (Array.fold ~f:(+.) ~init:0. a) /. (Float.of_int (n - 1))