#difference #distribution #normal #find #done #right #benchmarking

behrens-fisher

Find the difference of the means of two Normal distributions

2 unstable releases

0.2.0 Mar 2, 2022
0.1.0 Nov 30, 2020

#687 in Science

Download history 264/week @ 2023-12-13 143/week @ 2023-12-20 91/week @ 2023-12-27 209/week @ 2024-01-03 228/week @ 2024-01-10 70/week @ 2024-01-17 18/week @ 2024-01-24 23/week @ 2024-01-31 390/week @ 2024-02-07 1108/week @ 2024-02-14 487/week @ 2024-02-21 275/week @ 2024-02-28 174/week @ 2024-03-06 155/week @ 2024-03-13 158/week @ 2024-03-20 167/week @ 2024-03-27

690 downloads per month
Used in cbdr

Unlicense

32KB
677 lines

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.

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

let x_stats: SampleStats = x_sample.into_iter().collect();
let y_stats: SampleStats = y_sample.into_iter().collect();
let ci = difference_of_means(0.95, x_stats, y_stats).unwrap();
assert_eq!(ci.to_string(), "+4.50 ± 3.89 (p=95%)");
// Looks like μ[Y] > μ[X]!

Dependencies

~77KB