When the Friedman test rejects, the Nemenyi post-hoc test (Demsar, 2006) says which pairs differ. Two algorithms differ when their average ranks differ by at least the critical difference
CD = q_alpha * sqrt(k (k + 1) / (6 N)),
where k is the number of algorithms, N the number of datasets, and q_alpha is the studentized range statistic divided by sqrt(2) for the chosen alpha. For example, q_0.05 = 2.569 when k = 4.
Implement two functions:
nemenyi_cd(k, n, q_alpha) returns CD as a float.significantly_different(rank_a, rank_b, cd) returns True when abs(rank_a - rank_b) >= cd.k >= 2, n >= 1, and q_alpha > 0. Otherwise raise ValueError from nemenyi_cd.cd must be nonnegative. Otherwise raise ValueError from significantly_different.cd counts as significant.The critical difference grows with the square root of k (k + 1) and shrinks with the square root of N.
No results yet
Run your code to check it against the examples, or submit to run every test.