Trait test::stats::Stats

source ·
pub trait Stats {
Show 13 methods // Required methods fn sum(&self) -> f64; fn min(&self) -> f64; fn max(&self) -> f64; fn mean(&self) -> f64; fn median(&self) -> f64; fn var(&self) -> f64; fn std_dev(&self) -> f64; fn std_dev_pct(&self) -> f64; fn median_abs_dev(&self) -> f64; fn median_abs_dev_pct(&self) -> f64; fn percentile(&self, pct: f64) -> f64; fn quartiles(&self) -> (f64, f64, f64); fn iqr(&self) -> f64;
}
🔬This is a nightly-only experimental API. (test)
Expand description

一个 trait,它提供关于单变量数字样本集的简单描述性统计信息。

Required Methods§

source

fn sum(&self) -> f64

🔬This is a nightly-only experimental API. (test)

样本的总和。

Note: 这种方法牺牲了性能,准确性取决于 IEEE 754 算法保证。 请参见以下网址的正确性证明: “Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates”

source

fn min(&self) -> f64

🔬This is a nightly-only experimental API. (test)

样品的最小值。

source

fn max(&self) -> f64

🔬This is a nightly-only experimental API. (test)

样品的最大值。

source

fn mean(&self) -> f64

🔬This is a nightly-only experimental API. (test)

样本的算术平均值 (average): 总和除以样本数。

请参见:https://en.wikipedia.org/wiki/Arithmetic_mean

source

fn median(&self) -> f64

🔬This is a nightly-only experimental API. (test)

样本中位数:将样本下半部分与样本上半部分分开的值。 等于 self.percentile(50.0)

请参见:https://en.wikipedia.org/wiki/Median

source

fn var(&self) -> f64

🔬This is a nightly-only experimental API. (test)

样本方差:每个样本与样本均值之差的平方的偏差校正后的平均值。 请注意,这是计算 sample variance 而不是总体方差 (假定该方差是未知的)。 因此,通过除以 (n-1) 而不是 n,它可以纠正如果我们计算总体方差时出现的 (n-1)/n 偏差。

请参见:https://en.wikipedia.org/wiki/Variance

source

fn std_dev(&self) -> f64

🔬This is a nightly-only experimental API. (test)

标准偏差:样本方差的平方根。

Note: 对于非正态分布,这不是一个可靠的统计数据。 对于未知的发行版,最好使用 median_abs_dev

请参见:https://en.wikipedia.org/wiki/Standard_deviation

source

fn std_dev_pct(&self) -> f64

🔬This is a nightly-only experimental API. (test)

标准偏差,以平均值的百分比表示。请参见 std_devmean

Note: 对于非正态分布,这不是一个可靠的统计数据。 对于未知的发行版,最好使用 median_abs_dev_pct

source

fn median_abs_dev(&self) -> f64

🔬This is a nightly-only experimental API. (test)

每个样本与样本中位数的绝对偏差的标度中位数。 这是样本可变性的可靠 (distribution-agnostic) 估计器。 如果您不能假定样本是正态分布的,则优先使用 std_dev。 请注意,常量 1.4826 对它进行了缩放,以使其可用作标准偏差的一致估计量。

请参见:https://en.wikipedia.org/wiki/Median_absolute_deviation

source

fn median_abs_dev_pct(&self) -> f64

🔬This is a nightly-only experimental API. (test)

中位数绝对偏差占中位数的百分比。请参见 median_abs_devmedian

source

fn percentile(&self, pct: f64) -> f64

🔬This is a nightly-only experimental API. (test)

百分位数: self 中的值所占的 pct 百分比以下的值。 例如,percentile(95.0) 将返回值 v,以使 self 中 95% 的样本 s 满足 s <= v

通过最接近等级之间的线性插值计算。

请参见:https://en.wikipedia.org/wiki/Percentile

source

fn quartiles(&self) -> (f64, f64, f64)

🔬This is a nightly-only experimental API. (test)

样本四分位数:将样本分为四个相等组的三个值,每个组的数据为 1/4。 中间值为中间值。 请参见 medianpercentile。 与对 percentile 的 3 个调用相比,此函数可以更有效地计算 3 个四分位数,但在其他方面等效。

另请参见:https://en.wikipedia.org/wiki/Quartile

source

fn iqr(&self) -> f64

🔬This is a nightly-only experimental API. (test)

四分位间距:第 25 个百分位数 (第 1 个四分位数) 和第 75 个百分位数 (第 3 个四分位数) 之间的差。 请参见 quartiles

另请参见:https://en.wikipedia.org/wiki/Interquartile_range

Implementations on Foreign Types§

source§

impl Stats for [f64]

source§

fn sum(&self) -> f64

🔬This is a nightly-only experimental API. (test)
source§

fn min(&self) -> f64

🔬This is a nightly-only experimental API. (test)
source§

fn max(&self) -> f64

🔬This is a nightly-only experimental API. (test)
source§

fn mean(&self) -> f64

🔬This is a nightly-only experimental API. (test)
source§

fn median(&self) -> f64

🔬This is a nightly-only experimental API. (test)
source§

fn var(&self) -> f64

🔬This is a nightly-only experimental API. (test)
source§

fn std_dev(&self) -> f64

🔬This is a nightly-only experimental API. (test)
source§

fn std_dev_pct(&self) -> f64

🔬This is a nightly-only experimental API. (test)
source§

fn median_abs_dev(&self) -> f64

🔬This is a nightly-only experimental API. (test)
source§

fn median_abs_dev_pct(&self) -> f64

🔬This is a nightly-only experimental API. (test)
source§

fn percentile(&self, pct: f64) -> f64

🔬This is a nightly-only experimental API. (test)
source§

fn quartiles(&self) -> (f64, f64, f64)

🔬This is a nightly-only experimental API. (test)
source§

fn iqr(&self) -> f64

🔬This is a nightly-only experimental API. (test)

Implementors§