Skip to main content

two_sample_t_test

Function two_sample_t_test 

Source
pub fn two_sample_t_test(a: &[f64], b: &[f64]) -> Option<TestResult>
Expand description

Two-sample Welch t-test: H₀: μ₁ = μ₂ (unequal variances).

§Algorithm

t = (x̄₁ - x̄₂) / √(s₁²/n₁ + s₂²/n₂) df = Welch-Satterthwaite approximation.

§Returns

None if either sample has fewer than 2 observations.

§References

Welch (1947). “The generalization of Student’s problem when several different population variances are involved”. Biometrika, 34, 28–35.

§Examples

use u_analytics::testing::two_sample_t_test;

let a = [5.1, 4.9, 5.2, 5.0, 4.8];
let b = [7.1, 6.9, 7.2, 7.0, 6.8];
let r = two_sample_t_test(&a, &b).unwrap();
assert!(r.p_value < 0.01); // means clearly differ