package why3find

  1. Overview
  2. Docs
A Why3 Package Manager

Install

dune-project
 Dependency

Authors

Maintainers

Sources

why3find-1.3.0.tar.gz
md5=435da830a513fd91ec5411c91126b763
sha512=fd8b04eb16d569c0dc9e5595a40b174d7858121b080c81d459b2f28fb3af1ebc32ef408859d5c1c5f45c61790625c027c2ecfc3d45e597943543de7212bab8d6

doc/src/why3find.utils/stats.ml.html

Source file stats.ml

1
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