Skip to content

Commit

Permalink
No need to take Float.abs before squaring
Browse files Browse the repository at this point in the history
Thanks to @lyrm for noticing this.
  • Loading branch information
polytypic committed Feb 7, 2024
1 parent 42dbbc5 commit cf80b06
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/stats.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ let mean_of times =
Array.fold_left ( +. ) 0.0 times /. Float.of_int (Array.length times)

let sd_of times mean =
Float.sqrt (mean_of (Array.map (fun v -> Float.abs (v -. mean) ** 2.) times))
Float.sqrt
(mean_of
(Array.map
(fun v ->
let d = v -. mean in
d *. d)
times))

let median_of times =
Array.sort Float.compare times;
Expand Down

0 comments on commit cf80b06

Please sign in to comment.