当前位置:网站首页>Wilcoxon rank-sum 和 signed-rank
Wilcoxon rank-sum 和 signed-rank
2022-07-27 10:59:00 【想搞钱的小陈】
转载至:Wilcoxon 检验之 rank-sum 与 signed-rank_Yongfeng's Blog-CSDN博客
Wilcoxon rank-sum test和signed-rank test 经常在做时间序列分析的时候会用到,主要用于多个算法之间的对比 ,还有cd图。
1. Wilcoxon 秩和检验
用于判断2者算法是否有差异。计算每个算法对应数据集的排名(rank),然后把rank进行求和,得到R1,R2。然后计算U1和U2
U1=n1*n2+n1(n1+1)/2 -T
U2=n1*n2-U1
然后查 Wilcoxon 双尾临界表,如果U1<临界值,拒绝原假设,U1>临界值,接受原假设。(原假设是2个算法无差异)
from scipy import stats
def wilcoxon_rank_sum_test(x, y):
res = stats.mannwhitneyu(x ,y)
print(res)得到的结果有2个值,一个statistic,一个是p-value
> MannwhitneyuResult(statistic=6.5, pvalue=0.006966479792405637)
2. Wilcoxon 符号秩检验



最后,根据|W|查表,得到Wilcoxon 在α=0.05,n=9的时候的临界值为5,而我们计算出来的|w|=9>5,因此不能拒绝原假设,2者没有显著性差异。
from scipy import stats
def wilcoxon_signed_rank_test(y1, y2):
res = stats.wilcoxon(y1, y2)
print(res) 得到的结果如下,其中 statistic = 18.0,表示 2 类符号秩和较小的一个(w+和w-最小的是18);pvalue=0.5936,就是我们需要的p-value ,之所以出现Warning信息是因为我们的数据量太少,一般来讲大于 20 是比较合适做假设检验的。
> E:\Software\Anaconda2\lib\site-packages\scipy\stats\morestats.py:2397: UserWarning:
> Warning: sample size too small for normal approximation.
> warnings.warn("Warning: sample size too small for normal approximation.")
> WilcoxonResult(statistic=18.0, pvalue=0.5936305914425295)
边栏推荐
- Force buckle - 10. Regular expression matching
- 博弈论 AcWing 891. Nim游戏
- The C programming language (2nd) -- Notes -- 1.10
- Stack acwing 3302. Expression evaluation
- 状态压缩DP AcWing 91. 最短Hamilton路径
- (8) Shell function
- 什么是私域流量?
- Why choose smart TV?
- Longest ascending subsequence model acwing 272. longest common ascending subsequence
- Knapsack problem acwing 9. grouping knapsack problem
猜你喜欢

Moveit2 -- 2. Quick start of moveit in rviz

求组合数 AcWing 885. 求组合数 I

容斥原理 AcWing 890. 能被整除的数

数字三角形模型 AcWing 1018. 最低通行费

Digital triangle model acwing 1015. Picking flowers

Modelarts image classification and object detection

Gaussian elimination acwing 883. solving linear equations with Gaussian elimination

区间问题 AcWing 906. 区间分组

中国剩余定理 AcWing 204. 表达整数的奇怪方式

树形DP AcWing 285. 没有上司的舞会
随机推荐
Properties file
Luogu p1896 non aggression
SQL statement learning and the use of pymysql
Win10 vscode code code format setting and remote breakpoint debugging
LAN SDN technology hard core insider 12 cloud CP's daily love - hardware vxlan forwarding plane
zabbix自定义监控项
Redis simple to use
求组合数 AcWing 887. 求组合数 III
LAN SDN hard core technology insider 23 looking forward to the future - RDMA (Part 1)
(9) Shell I / O redirection
C# 自定义集合
局域网SDN技术硬核内幕 11 云网融合CP的关键——层次化端口绑定
(4) Operator
Find the combination number acwing 888. find the combination number IV
你真的会写二分查找吗——变种二分查找
求组合数 AcWing 888. 求组合数 IV
博弈论 AcWing 893. 集合-Nim游戏
Interval problem acwing 906. Interval grouping
A deep analysis of the soul of C language -- pointer
Basic use of cmake