mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
Extract quantity and command helpers
This commit is contained in:
1 parent
ecf8a24b1e
commit
b5f58651a1
5 files changed
+20
-12
No files matched your search
@@ -112,7 +112,7 @@ pub fn standard_deviation<Q: UnsafeRawValue>(values: &[Q], mean: Q) -> Q {
|
||||
///
|
||||
/// References:
|
||||
/// - <https://en.wikipedia.org/wiki/Median_absolute_deviation>
|
||||
pub fn modified_zscores(xs: &[f64]) -> Vec<f64> {
|
||||
pub fn modified_zscores_f64(xs: &[f64]) -> Vec<f64> {
|
||||
assert!(!xs.is_empty());
|
||||
|
||||
// Compute sample median:
|
||||
@@ -131,6 +131,11 @@ pub fn modified_zscores(xs: &[f64]) -> Vec<f64> {
|
||||
xs.iter().map(|&x| (x - x_median) / mad).collect()
|
||||
}
|
||||
|
||||
pub fn modified_zscores<Q: UnsafeRawValue>(values: &[Q]) -> Vec<f64> {
|
||||
let values: Vec<_> = values.iter().map(|q| q.unsafe_raw_value()).collect();
|
||||
modified_zscores_f64(&values)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in new issue
Block a user