0
$\begingroup$

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
seed(1)
# generate two independent samples


a=np.array([125,115,130,140,140,115,140,125,140,135])
b=np.array([110,122,125,120,140,124,123,137,135,145])

# 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)')
else:
    print('Different distribution (reject H0)')
$\endgroup$
1
$\begingroup$

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$

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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