Skip to main content

wilcoxon_signed_rank

Function wilcoxon_signed_rank 

pub fn wilcoxon_signed_rank(differences: &[f64]) -> WilcoxonReport
Expand description

The paired Wilcoxon signed-rank statistic of a set of differences.

Zero and non-finite differences are dropped (the standard Pratt-free treatment of ties-at-zero); the absolute values of the rest are ranked with average ranks for ties, and the ranks are summed by sign into W⁺/W⁻. The tie structure is retained so WilcoxonReport::one_sided_p can correct the variance.

use atune_core::scheduler::wilcoxon_signed_rank;

// Differences with distinct magnitudes 0.1..0.9; two are negative (0.1, 0.2).
let d = [0.5, 0.7, -0.2, 0.9, 0.3, -0.1, 0.4, 0.8];
let report = wilcoxon_signed_rank(&d);
assert_eq!(report.pairs, 8);
assert_eq!(report.w_minus, 3.0); // ranks 1 + 2 of the two negatives
assert_eq!(report.w_plus, 33.0); // 36 total − 3