Lines Matching +full:robust +full:- +full:predicates
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
17 fn local_cmp(x: f64, y: f64) -> Ordering { in local_cmp()
41 /// Depends on IEEE-754 arithmetic guarantees. See proof of correctness at:
42 /// ["Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates"]
43 /// (http://www.cs.cmu.edu/~quake-papers/robust-arithmetic.ps)
44 fn sum(&self) -> f64; in sum()
47 fn min(&self) -> f64; in min()
50 fn max(&self) -> f64; in max()
52 /// Arithmetic mean (average) of the samples: sum divided by sample-count.
55 fn mean(&self) -> f64; in mean()
61 fn median(&self) -> f64; in median()
63 /// Variance of the samples: bias-corrected mean of the squares of the differences of each
65 /// population variance, which is assumed to be unknown. It therefore corrects the `(n-1)/n`
66 /// bias that would appear if we calculated a population variance, by dividing by `(n-1)` rather
70 fn var(&self) -> f64; in var()
74 /// Note: this is not a robust statistic for non-normal distributions. Prefer the
78 fn std_dev(&self) -> f64; in std_dev()
82 /// Note: this is not a robust statistic for non-normal distributions. Prefer the
84 fn std_dev_pct(&self) -> f64; in std_dev_pct()
87 /// robust (distribution-agnostic) estimator of sample variability. Use this in preference to
93 fn median_abs_dev(&self) -> f64; in median_abs_dev()
96 fn median_abs_dev_pct(&self) -> f64; in median_abs_dev_pct()
105 fn percentile(&self, pct: f64) -> f64; in percentile()
113 fn quartiles(&self) -> (f64, f64, f64); in quartiles()
115 /// Inter-quartile range: the difference between the 25th percentile (1st quartile) and the 75th
119 fn iqr(&self) -> f64; in iqr()
142 pub fn new(samples: &[f64]) -> Summary { in new()
162 fn sum(&self) -> f64 { in sum()
175 // Rounded `x+y` is stored in `hi` with round-off stored in in sum()
178 let lo = y - (hi - x); in sum()
196 fn min(&self) -> f64 { in min()
201 fn max(&self) -> f64 { in max()
206 fn mean(&self) -> f64 { in mean()
211 fn median(&self) -> f64 { in median()
215 fn var(&self) -> f64 { in var()
222 let x = *s - mean; in var()
225 // NB: this is _supposed to be_ len-1, not len. If you in var()
228 let denom = (self.len() - 1) as f64; in var()
233 fn std_dev(&self) -> f64 { in std_dev()
237 fn std_dev_pct(&self) -> f64 { in std_dev_pct()
242 fn median_abs_dev(&self) -> f64 { in median_abs_dev()
244 let abs_devs: Vec<f64> = self.iter().map(|&v| (med - v).abs()).collect(); in median_abs_dev()
251 fn median_abs_dev_pct(&self) -> f64 { in median_abs_dev_pct()
256 fn percentile(&self, pct: f64) -> f64 { in percentile()
262 fn quartiles(&self) -> (f64, f64, f64) { in quartiles()
274 fn iqr(&self) -> f64 { in iqr()
276 c - a in iqr()
281 // Helper function: extract a value representing the `pct` percentile of a sorted sample-set, using
283 fn percentile_of_sorted(sorted_samples: &[f64], pct: f64) -> f64 { in percentile_of_sorted()
293 return sorted_samples[sorted_samples.len() - 1]; in percentile_of_sorted()
295 let length = (sorted_samples.len() - 1) as f64; in percentile_of_sorted()
298 let d = rank - lrank; in percentile_of_sorted()
302 lo + (hi - lo) * d in percentile_of_sorted()
306 /// Winsorize a set of samples, replacing values above the `100-pct` percentile
318 let hi = percentile_of_sorted(&tmp, hundred - pct); in winsorize()
328 // Test vectors generated from R, using the script src/etc/stat-test-vectors.r.
341 assert!((*a - *b).abs() < 1.0e-6,
361 // but they're within float epsilon, which is 1.0e-6. in check()
875 assert_eq!([1e30f64, 1.2f64, -1e30f64].sum(), 1.2); in test_sum_f64_between_ints_that_sum_to_0()