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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Numeric Statistics provides functions for min, max, average, variance, standard deviation, and more to come.
```rust
use numeric_statistics::assert_eq_f64;
use numeric_statistics::f64::{
};
let values = &[1.0, 2.0, 4.0];
let min = min(values);
let max = max(values);
let average = average(values);
let variance = variance(values);
let standard_deviation = standard_deviation(values);
assert_eq!(min, 1.0);
assert_eq!(max, 4.0);
assert_eq_f64!(average, 2.3333333333333333 as f64);
assert_eq_f64!(variance, 2.3333333333333333 as f64);
assert_eq_f64!(standard_deviation, 1.5275252316519465 as f64);
```
You can get all the numeric statistics in one struct like this:
```rust
use numeric_statistics::assert_eq_f64;
use use numeric_statistics::all::All;
let values = &[1.0, 2.0, 4.0];
use numeric_statistics::f64::all::All;
assert_eq!(all.min, 1.0);
assert_eq!(all.max, 4.0);
assert_eq_f64!(all.average, 2.3333333333333333 as f64);
assert_eq_f64!(all.variance, 2.3333333333333333 as f64);
assert_eq_f64!(all.standard_deviation, 1.5275252316519465 as f64);
```
This is a work-in-progress to translate the Num Command software from POSIX into Rust.
<https://github.com/numcommand/num>