cliffgao的个人博客分享 http://blog.sciencenet.cn/u/cliffgao 兴趣:生物信息学、统计、概率

博文

python 中Wilcoxon rank-sum 和 R 中的 wilcox.test

已有 11143 次阅读 2016-12-21 23:10 |个人分类:python|系统分类:科研笔记

python 中Wilcoxon rank-sum 和 R 中的 wilcox.test


参考网页:http://stackoverflow.com/questions/12797658/pythons-scipy-stats-ranksums-vs-rs-wilcox-test


python scipy 中的 ranksums(x,y) 相当于  

R中的 wilcox.text(x,y,exact=FALSE,correct=FALSE)


#### python  code


x=[57.07168,46.95301,31.86423,38.27486,77.89309,76.78879,33.29809,58.61569,18.26473,62.92256,50.46951,19.14473,22.58552,24.14309]

y=[8.319966,2.569211,1.306941,8.450002,1.624244,1.887139,1.376355,2.521150,5.940253,1.458392,3.257468,1.574528,2.338976]

scipy.stats.ranksums(x, y)

(4.415880433163923, 1.0059968254463979e-05)




####  r code

x=c(57.07168,46.95301,31.86423,38.27486,77.89309,76.78879,33.29809,58.61569,18.26473,62.92256,50.46951,19.14473,22.58552,24.14309)

y=c(8.319966,2.569211,1.306941,8.450002,1.624244,1.887139,1.376355,2.521150,5.940253,1.458392,3.257468,1.574528,2.338976)


wilcox.test(x, y, exact=FALSE, correct=FALSE)


   Wilcoxon rank sum test


data:  x and y

W = 182, p-value = 1.006e-05

alternative hypothesis: true location shift is not equal to 0




scipy.stats.ranksums(x, y)[source]

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. For tie-handling and an optional continuity correction see scipy.stats.mannwhitneyu.




https://wap.sciencenet.cn/blog-468005-1022320.html

上一篇:R 类型转化
下一篇:如何看待数据
收藏 IP: 111.165.10.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-20 20:31

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部