这取决于您使用的选项。检查以下示例:
1-MATLABrng('default') % for reproducibility
x = unifrnd(0,1,20,1);
y = unifrnd(0.25,1.25,20,1);
p = ranksum(x,y);
p =
0.2503
2-Python
(为了保持一致,我没有再次生成数字,但是我已经将MATLAB中生成的数字移动到Python脚本中)
^{pr2}$
此结果包含以下选项:
1-对于MATLAB:p = ranksum(x,y) returns the p-value of a two-sided Wilcoxon rank sum
test. ranksum tests the null hypothesis that data in x and y are
samples from continuous distributions with equal medians, against the
alternative that they are not. The test assumes that the two samples
are independent. x and y can have different lengths. This test is
equivalent to a Mann-Whitney U-test.
2-对于Python:Compute the Wilcoxon rank-sum statistic for two samples. The
Wilcoxon rank-sum 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.
另一个例子
这里我使用的是相同的数据,具有相同的MATLAB功能,但有不同的选择。现在您可以看到结果等于Scipy中mannwhitneyu函数的结果。在
MATLAB[p,h,stats] = ranksum(x,y,'alpha',0.01,'tail','left','method','exact');
p =
0.1267
Pythonm = mannwhitneyu(xx, yy, use_continuity=True)
print m
MannwhitneyuResult(statistic=157.0, pvalue=0.12514839875175593)