Brown-Mood Median Test

对于两独立样本尺度中的位置参数(中位数)检验问题:

\(H_0: med_x = med_y\)   \(H_1=med_x > med_y\)

在\(H_0\)假设下,两组数据具有相同的中位数

对于X,Y两组数据组成的两个数组,进行中位数比较。

核心是比较\(med_xy\) 和\(med_x\) \(med-y\)的关系。

X Y sum
>\(M_{xy}\) A B t
<\(M_{xy}\) C D (m+n)-(A+B)
\(\sum\) m n m=n=A+B+C+D

when m,n,t are fixed.

则A的密度函数如下:

\(P(A=k)=\frac{\binom{m}{k}\binom{n}{n-k}}{\binom{m+n}{t}}\), k\(\leqslant\) min{m,t}

以下是Brown-Mood R代码

#Brown-Mood median test
BM.test <- function(x,y,alt)
{
xy <- c(x,y)
md.xy <-median(xy)
t <- sum(xy > md.xy)
lx <- length(x)
ly <- length(y)
lxy <- lx + ly
A <- sum(x > md.xy)
if(alt == "greater")
{w <- 1 - phyper(A,lx,ly,t)}
else if (alt == "less")
{w <- phyper(A,lx,ly,t)}
conting.table = matrix(c(A,lx-A,lx,t-A,ly-(t-A),ly,t,lxy-t,lxy),3,3)
col.name <- c("X","Y","X+Y")
row.name <- c(">MXY","<MXY","TOTAL")
dimnames(conting.table)<-list(row.name,col.name)
list(contingencu.table=conting.table,p.value = w)
}

这里要特别注意phyper()函数的参数中关于 lower.tail = TRUE 和 FALSE的定义,防止出现多余计算。

\[phyper(q,m,n,k) = \frac{\binom{m}{k}\binom{n}{n-k}}{\binom{m+n}{t}}, k\leqslant min(m,t)
\]

大样本计算时,趋于正态分布:

binom 分布的 $$E[X] = μ = t\cdot\frac{m}{m+n}$$

\[D[x]
\]

example:

x <- c(698,688,675,656,655,648,640,639,620)
y <- c(780,754,740,712,693,680,621) BM.test(x,y,"less")
$contingencu.table
X Y X+Y
>MXY 2 6 8
<MXY 7 1 8
TOTAL 9 7 16

Brown Mood Median Test的更多相关文章

  1. No.004:Median of Two Sorted Arrays

    问题: There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the ...

  2. [LeetCode] Find Median from Data Stream 找出数据流的中位数

    Median is the middle value in an ordered integer list. If the size of the list is even, there is no ...

  3. [LeetCode] Median of Two Sorted Arrays 两个有序数组的中位数

    There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two ...

  4. Applying vector median filter on RGB image based on matlab

    前言: 最近想看看矢量中值滤波(Vector median filter, VMF)在GRB图像上的滤波效果,意外的是找了一大圈却发现网上没有现成的code,所以通过matab亲自实现了一个,需要学习 ...

  5. 【leetcode】Median of Two Sorted Arrays

    题目简述: There are two sorted arrays A and B of size m and n respectively. Find the median of the two s ...

  6. Codeforces Round #327 (Div. 2) B. Rebranding C. Median Smoothing

    B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. T ...

  7. 【leedcode】 Median of Two Sorted Arrays

    https://leetcode.com/problems/median-of-two-sorted-arrays/ There are two sorted arrays nums1 and num ...

  8. Find Median from Data Stream

    常规方法 超时 class MedianFinder { vector<int> coll; public: MedianFinder(){ } void heapfu(vector< ...

  9. 数据结构与算法(1)支线任务8——Find Median from Data Stream

    题目如下:(https://leetcode.com/problems/find-median-from-data-stream/) Median is the middle value in an ...

随机推荐

  1. neo4j-rest-client使用摘要

    1.使用它的原因,与django搭配的最好的neomodel目前只支持到v2.2,我已给官方发了issue,官方也回复了,马上修改并发布(老外对开源项目的负责态度让人感动) 2.这个库的文档中大概描述 ...

  2. python3学习笔记4---引用http://python3-cookbook.readthedocs.io/zh_CN/latest/

    2018-03-01数据结构与算法(4) 1.16过滤序列元素 最简单的过滤序列元素的方法就是使用列表推导.比如: >>> mylist = [1, 4, -5, 10, -7, 2 ...

  3. 2018 CISCN reverse wp

    2018 CISCN reverse wp 这题比赛的时候没做出来,主要是心态崩了看不下去..赛后看了下网上的wp发现不难,是自己想复杂了.这里将我的思路和exp放出来,希望大家一起交流学习. mai ...

  4. Java父类对象调用子类实体:方法重写与动态调用

    众所周知Java的handle和C++的ponter而不是object对应,我们很熟悉C++的父类pointer调用子类实体的例子,那么对于Java的handle是不是也可以这样呢? 这里我先给一个例 ...

  5. Cocos2d-x 实战

    跨平台商业项目实战:攻城大作战游戏创意触发点:做什么样的游戏?分析当前主流的游戏:经典游戏(俄罗斯方块).大众化的游戏(卡牌游戏.休闲游戏).重口味游戏. 游戏创意:生活当中 游戏开发流程:1.策划方 ...

  6. vim快捷键汇总

    命令历史 以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择某个历史命令. 启动vim 在命令行窗口中输入以下命令即可 vim 直接启动vim vim filename 打开vim ...

  7. memset库函数

    头文件:#include <string.h>   定义函数:void * memset(void *s, int c, size_t n);   函数说明:memset()会将参数s 所 ...

  8. 使用ADO.NET操作数据库

    如有转载的请注明出处!蟹蟹 1.1使用对象连接OLE DB 数据源 OLE DB 数据源包含具有OLE DB 驱动程序的任何数据源,如SQL Server.Access.Excel.Oracle等. ...

  9. 最近面了不少java开发,据此来说下我的感受:哪怕事先只准备1小时,成功概率也能大大提升

    本人最近几年一直在做java后端方面的技术面试官,而在最近两周,又密集了面试了一些java初级和高级开发的候选人,在面试过程中,我自认为比较慎重,遇到问题回答不好的候选人,我总会再三从不同方面提问,只 ...

  10. c语言,数据结构,链表的一些操作总结

    下面是自己的一些学习操作以及总结,能用我会很开心,有不足之处,欢迎大家提出宝贵的意见! c语言链表是一种基本的数据结构,与顺序表一样属于线性表,但是顺序表在内存中的存储单元是连续的,这样就对内存的要求 ...