I use data from https://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test, W value is 9. But, for the following code W value is 18, what is the reason?

# Wilcoxon signed-rank test
from numpy.random import seed
from numpy.random import randn
from scipy.stats import wilcoxon
# seed the random number generator
# generate two independent samples


# compare samples
stat, p = wilcoxon(a,b)
print('Statistics=%.3f, p=%.3f' % (stat, p))
# interpret
alpha = 0.05
if p > alpha:
    print('Same distribution (fail to reject H0)')
    print('Different distribution (reject H0)')

1 Answer 1


If you look at the wikipedia page of Wilcoxon signed-rank test, under the section of the original test, it's mentioned that

The original Wilcoxon's proposal used a different statistic. Denoted by Siegel as the $T$ statistic, it is the smaller of the two sums of ranks of given sign; in the example given below, therefore, $T$ would equal $3+4+5+6=18$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.