use-statistics 0.0.2

Utility-first statistics scaffolding for RustUse
Documentation

use-statistics

Install

[dependencies]
use-statistics = "0.0.1"

Foundation

use-statistics provides a deliberately small descriptive-statistics surface over f64 slices. The crate currently exposes arithmetic mean, median, population variance, sample variance, and matching standard-deviation helpers, along with an explicit StatisticsError for empty inputs and too-small samples. The first slice stays simple and direct instead of introducing a full dataframe or distribution framework.

Helper group Primary items Best fit
Central tendency mean, median Small apps and utilities that need direct descriptive summaries
Dispersion population_variance, sample_variance, population_std_dev, sample_std_dev Call sites that should remain explicit about population vs. sample summaries
Error handling StatisticsError Code that needs predictable handling for empty or undersized inputs

When to use directly

Choose use-statistics directly when statistical summaries or distributions are the only surface you need and you want to keep that concern narrower than the full facade.

Scenario Use use-statistics directly? Why
You need descriptive summaries over f64 slices Yes The current API already covers the common location and dispersion cases directly
You want explicit population-vs-sample summary functions Yes The function names keep estimator choice visible at the call site
You also need probability, calculus, or other math domains Usually no use-math can compose the concrete surfaces behind features

Scope

  • The current surface is intentionally small and concrete.
  • Helpers operate over borrowed f64 slices instead of introducing dataset wrapper types.
  • Probability primitives and broader numerical analysis belong in adjacent focused crates.

Examples

Central tendency and population summaries

use use_statistics::{mean, median, population_std_dev, population_variance};

let values = [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0];

assert!((mean(&values)? - 5.0).abs() < 1.0e-12);
assert!((median(&values)? - 4.5).abs() < 1.0e-12);
assert!((population_variance(&values)? - 4.0).abs() < 1.0e-12);
assert!((population_std_dev(&values)? - 2.0).abs() < 1.0e-12);
# Ok::<(), use_statistics::StatisticsError>(())

Sample summaries

use use_statistics::{sample_std_dev, sample_variance};

let sample = [1.0, 2.0, 3.0, 4.0];

assert!((sample_variance(&sample)? - 1.666_666_666_666_666_7).abs() < 1.0e-12);
assert!((sample_std_dev(&sample)? - 1.290_994_448_735_805_6).abs() < 1.0e-12);
# Ok::<(), use_statistics::StatisticsError>(())

Status

use-statistics is a concrete pre-1.0 crate in the RustUse docs surface. The API remains intentionally small while adjacent probability and numeric-analysis crates continue to grow around it.