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
use std::cmp;
use {ErrorKind, Result};
#[derive(Debug, Clone, Copy, PartialOrd, PartialEq)]
pub struct Quantile(f64);
impl Quantile {
pub fn new(quantile: f64) -> Result<Self> {
track_assert!(
0.0 <= quantile && quantile <= 1.0,
ErrorKind::InvalidInput,
"quantile:{}",
quantile
);
Ok(Quantile(quantile))
}
pub fn as_f64(&self) -> f64 {
self.0
}
}
impl Ord for Quantile {
fn cmp(&self, other: &Self) -> cmp::Ordering {
self.partial_cmp(other).expect("Never fails")
}
}
impl Eq for Quantile {}