Advanced

Statistical comparison between algorithms

Statistical Comparison of Algorithms

Estimated duration
35 minutes
Related questions
20
Related algorithms
0
Status
Log in to track

Lesson objectives

  • Choose the appropriate statistical test for the comparison.
  • Apply Wilcoxon, Friedman and post-hoc tests.
  • Report results transparently.

Explanation

Stochastic algorithms give different results on every run; comparing two means without a statistical test can lead to wrong conclusions.

Recommended procedure (Derrac et al. 2011; Carrasco et al. 2020; LaTorre et al. 2021): run R independent runs (usually 25–51) of each algorithm on each function/dataset with an equal evaluation budget.

Two algorithms on one problem: the Mann-Whitney U test (independent samples) or the Wilcoxon signed-rank test when paired (same seeds or same folds). Two algorithms on several problems: Wilcoxon on the problem means. More than two algorithms on several problems: Friedman (or Aligned Friedman/Quade), then post-hoc tests with a correction for multiple comparisons (Holm or Finner).

Report: the mean, standard deviation, median, best and worst values, the effect size, and the corrected p-values. A lack of statistical significance does not mean equivalence.

Method AMethod BMethod CDistribution of the best fitness over 30 runs (an illustration, not real data)
The box plot reveals the variance between runs, not only the mean.

Mathematics

Friedman statistic

\chi_F^2 = \frac{12N}{k(k+1)}\left[\sum_j R_j^2 - \frac{k(k+1)^2}{4}\right]

N is the number of problems, k the number of algorithms, R_j the mean rank.

Python code

import numpy as np
from scipy.stats import wilcoxon, friedmanchisquare
rng = np.random.default_rng(0)
a, b, c = rng.normal(1.0, .2, 30), rng.normal(1.1, .2, 30), rng.normal(1.3, .2, 30)
print(wilcoxon(a, b).pvalue)
print(friedmanchisquare(a, b, c).pvalue)

Simplified teaching code that works with NumPy only; for research experiments use a documented library and fix the random seed.

Practical exercise

In the simulator's comparison mode run 10 runs per algorithm; the lab shows the mean, deviation, best and worst result, and an approximate Wilcoxon test.

Common mistakes

  • Using a t-test with non-normal distributions and small samples.
  • Running dozens of pairwise comparisons without correction.
  • Judging from a single run.

Summary

Compare with several runs and an equal budget, and use non-parametric tests with a correction for multiple comparisons.

References

Related papers in the repository

Short quiz

5 questions are chosen at random from 20 questions linked to this lesson, and the quiz is graded on the server.

Links within the lab

Related lessons
In the paths