Crate average [−] [src]
This crate provides estimators for the weighted and unweighted average of a sequence of numbers, and for their standard errors. The typical workflow looks like this:
- Initialize your estimator of choice (
Average
,AverageWithError
,WeightedAverage
orWeightedAverageWithError
) withnew()
. - Add some subset (called "samples") of the sequence of numbers (called
"population") for which you want to estimate the average, using
add()
orcollect()
. - Calculate the arithmetic mean with
mean()
and its standard error witherror()
.
You can run several estimators in parallel and merge them into one with
merge()
.
Example
use average::AverageWithError; let mut a: AverageWithError = (1..6).map(Into::into).collect(); a.add(42.); println!("The average is {} ± {}.", a.mean(), a.error());
Macros
assert_almost_eq |
Assert that two numbers are almost equal to each other. |
Structs
Average |
Estimate the arithmetic mean of a sequence of numbers ("population"). |
AverageWithError |
Estimate the arithmetic mean and the variance of a sequence of numbers ("population"). |
WeightedAverage |
Estimate the weighted and unweighted arithmetic mean of a sequence of numbers ("population"). |
WeightedAverageWithError |
Estimate the weighted and unweighted arithmetic mean and the unweighted variance of a sequence of numbers ("population"). |