[][src]Crate behrens_fisher

A crate for testing whether the means of two Normal distributions are the same.

This crate implements Welch's t-test, an approximate solution to the Behrens-Fisher problem. The results are presented in the form of a confidence interval.

Example

Suppose we have a population distributed as X (normal), and another distributed as Y (also normal, but possibly with different mean/variance to X). Let's take a sample from each population to estimate the difference between the population means.

let x_sample: Vec<f64> = vec![1., 2., 3., 4.];
let y_sample: Vec<f64> = vec![3., 5., 7., 9., 11.];

let x_stats = x_sample.into_iter().collect::<Stats>();
let y_stats = y_sample.into_iter().collect::<Stats>();
let width = confidence_interval(0.95, x_stats, y_stats).unwrap();
let msg = format!(
    "Δ = {:+.2} ± {:.2} (p=95%)",
    y_stats.mean - x_stats.mean,
    width,
);
assert_eq!(msg, "Δ = +4.50 ± 3.89 (p=95%)");
// Looks like μ[Y] > μ[X]!

Modules

student_t

Structs

Stats

Statictics for a sample taken from a normally-distributed population.

StatsBuilder

Enums

Error

Functions

confidence_interval

A confidence interval for y.mean - x.mean. This function returns the half-width of the confidence interval, ie. the i in y.mean - x.mean ± i.