Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
stats.ml1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34(**************************************************************************) (* *) (* SPDX-License-Identifier LGPL-2.1 *) (* Copyright (C) *) (* CEA (Commissariat à l'énergie atomique et aux énergies alternatives) *) (* *) (**************************************************************************) type stats = { mutable min : float; mutable max : float; mutable sum : float; mutable count : int; } let create () = { min = infinity; max = neg_infinity; sum = 0.; count = 0; } let add s x = s.count <- s.count + 1; s.sum <- s.sum +. x; s.min <- min s.min x; s.max <- max s.max x let norm f = if Float.is_finite f then f else 0.0 let min s = norm s.min let max s = norm s.max let sum s = s.sum let count s = s.count let average s = if s.count = 0 then 0.0 else s.sum /. float_of_int s.count