pub fn levene_test(groups: &[&[f64]]) -> Option<TestResult>Expand description
Levene test for equality of variances: H₀: all groups have equal variance.
Robust to non-normality. Uses the median variant (Brown-Forsythe), which is recommended for non-normal data.
§Algorithm
- Compute zᵢⱼ = |xᵢⱼ - median(groupᵢ)|
- Apply one-way ANOVA on the zᵢⱼ values
§Returns
None if fewer than 2 groups, any group < 2 observations, or non-finite values.
§References
- Levene (1960). “Robust tests for equality of variances”. In Olkin (Ed.), Contributions to Probability and Statistics.
- Brown & Forsythe (1974). “Robust tests for the equality of variances”. JASA, 69(346), 364–367.
§Examples
use u_analytics::testing::levene_test;
let g1 = [4.9, 5.0, 5.0, 5.1, 5.0]; // tight cluster (low variance)
let g2 = [0.0, 3.0, 5.0, 7.0, 10.0]; // wide spread (high variance)
let r = levene_test(&[&g1, &g2]).unwrap();
assert!(r.p_value < 0.05); // clear variance difference