test_friedman performs the Friedman two-way analysis of variance by ranks on related samples of size .

For full information please refer to the NAG Library document for g08ae

xfloat, array-like, shape

must be set to the value, , of observation in sample , for , for .


The value of the Friedman test statistic, .


The approximate significance, , of the Friedman test statistic.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .


In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.

The Friedman test investigates the score differences between matched samples of size , the scores in the th sample being denoted by

(Thus the sample scores may be regarded as a two-way table with rows and columns.) The hypothesis under test, , often called the null hypothesis, is that the samples come from the same population, and this is to be tested against the alternative hypothesis that they come from different populations.

The test is based on the observed distribution of score rankings between the matched observations in different samples.

The test proceeds as follows

  1. The scores in each column are ranked, denoting the rank within column of the observation in row . Average ranks are assigned to tied scores.

  2. The ranks are summed over each row to give rank sums , for .

  3. The Friedman test statistic is computed, where

test_friedman returns the value of , and also an approximation, , to the significance of this value. ( approximately follows a distribution, so large values of imply rejection of ). is rejected by a test of chosen size if . The approximation is acceptable unless and , or and , or and ; for , tables should be consulted (e.g., Siegel (1956)); for the Sign test (see test_sign()) or Wilcoxon test (see test_wilcoxon()) is in any case more appropriate.


Siegel, S, 1956, Non-parametric Statistics for the Behavioral Sciences, McGraw–Hill