# [−][src]Trait test::stats::Stats

    pub trait Stats {
        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`)

Trait that provides simple descriptive statistics on a univariate set of numeric samples.

## Required methods

### `fn sum(&self) -> f64`

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

Sum of the samples.

Note: this method sacrifices performance at the altar of accuracy Depends on IEEE-754 arithmetic guarantees. See proof of correctness at: "Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates"

### `fn min(&self) -> f64`

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

Minimum value of the samples.

### `fn max(&self) -> f64`

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

Maximum value of the samples.

### `fn mean(&self) -> f64`

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

Arithmetic mean (average) of the samples: sum divided by sample-count.

See: https://en.wikipedia.org/wiki/Arithmetic_mean

### `fn median(&self) -> f64`

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

Median of the samples: value separating the lower half of the samples from the higher half. Equal to `self.percentile(50.0)`.

See: https://en.wikipedia.org/wiki/Median

### `fn var(&self) -> f64`

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

Variance of the samples: bias-corrected mean of the squares of the differences of each sample from the sample mean. Note that this calculates the sample variance rather than the population variance, which is assumed to be unknown. It therefore corrects the `(n-1)/n` bias that would appear if we calculated a population variance, by dividing by `(n-1)` rather than `n`.

See: https://en.wikipedia.org/wiki/Variance

### `fn std_dev(&self) -> f64`

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

Standard deviation: the square root of the sample variance.

Note: this is not a robust statistic for non-normal distributions. Prefer the `median_abs_dev` for unknown distributions.

See: https://en.wikipedia.org/wiki/Standard_deviation

### `fn std_dev_pct(&self) -> f64`

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

Standard deviation as a percent of the mean value. See `std_dev` and `mean`.

Note: this is not a robust statistic for non-normal distributions. Prefer the `median_abs_dev_pct` for unknown distributions.

### `fn median_abs_dev(&self) -> f64`

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

Scaled median of the absolute deviations of each sample from the sample median. This is a robust (distribution-agnostic) estimator of sample variability. Use this in preference to `std_dev` if you cannot assume your sample is normally distributed. Note that this is scaled by the constant `1.4826` to allow its use as a consistent estimator for the standard deviation.

See: https://en.wikipedia.org/wiki/Median_absolute_deviation

### `fn median_abs_dev_pct(&self) -> f64`

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

Median absolute deviation as a percent of the median. See `median_abs_dev` and `median`.

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

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

Percentile: the value below which `pct` percent of the values in `self` fall. For example, percentile(95.0) will return the value `v` such that 95% of the samples `s` in `self` satisfy `s <= v`.

Calculated by linear interpolation between closest ranks.

See: https://en.wikipedia.org/wiki/Percentile

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

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

Quartiles of the sample: three values that divide the sample into four equal groups, each with 1/4 of the data. The middle value is the median. See `median` and `percentile`. This function may calculate the 3 quartiles more efficiently than 3 calls to `percentile`, but is otherwise equivalent.

See also: https://en.wikipedia.org/wiki/Quartile

### `fn iqr(&self) -> f64`

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

Inter-quartile range: the difference between the 25th percentile (1st quartile) and the 75th percentile (3rd quartile). See `quartiles`.

See also: https://en.wikipedia.org/wiki/Interquartile_range

Loading content...

## Implementations on Foreign Types

### `impl Stats for [f64]`[src]

#### `fn sum(&self) -> f64`[src]

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

#### `fn min(&self) -> f64`[src]

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

#### `fn max(&self) -> f64`[src]

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

#### `fn mean(&self) -> f64`[src]

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

#### `fn median(&self) -> f64`[src]

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

#### `fn var(&self) -> f64`[src]

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

#### `fn std_dev(&self) -> f64`[src]

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

#### `fn std_dev_pct(&self) -> f64`[src]

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

#### `fn median_abs_dev(&self) -> f64`[src]

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

#### `fn median_abs_dev_pct(&self) -> f64`[src]

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

#### `fn percentile(&self, pct: f64) -> f64`[src]

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

#### `fn quartiles(&self) -> (f64, f64, f64)`[src]

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

#### `fn iqr(&self) -> f64`[src]

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

## Implementors

Loading content...