scipy.stats.ranksums¶

scipy.stats.
ranksums
(x, y)[source]¶ Compute the Wilcoxon ranksum statistic for two samples.
The Wilcoxon ranksum test tests the null hypothesis that two sets of measurements are drawn from the same distribution. The alternative hypothesis is that values in one sample are more likely to be larger than the values in the other sample.
This test should be used to compare two samples from continuous distributions. It does not handle ties between measurements in x and y. For tiehandling and an optional continuity correction see
scipy.stats.mannwhitneyu
. Parameters
 x,yarray_like
The data from the two samples.
 Returns
 statisticfloat
The test statistic under the largesample approximation that the rank sum statistic is normally distributed.
 pvaluefloat
The twosided pvalue of the test.
References
Examples
We can test the hypothesis that two independent unequalsized samples are drawn from the same distribution with computing the Wilcoxon ranksum statistic.
>>> from scipy.stats import ranksums >>> sample1 = np.random.uniform(1, 1, 200) >>> sample2 = np.random.uniform(0.5, 1.5, 300) # a shifted distribution >>> ranksums(sample1, sample2) RanksumsResult(statistic=7.887059, pvalue=3.09390448e15) # may vary
The pvalue of less than
0.05
indicates that this test rejects the hypothesis at the 5% significance level.