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. linux(centos 7)学习之 ~目录下的文件anaconda-ks.cfg

    这个文件是记录安装系统的一些信息 #version=DEVEL # System authorization information auth --enableshadow --passalgo=sh ...

  2. 如何找某个样式属于哪个Element

    如果找不到样式所在的Element,那么可以参考排除法,逐个删除覆盖在同一位置的元素,如果该样式消失,那么可以判断为这个样式.

  3. 开发自己的 chart - 每天5分钟玩转 Docker 容器技术(167)

    Kubernetes 给我们提供了大量官方 chart,不过要部署微服务应用,还是需要开发自己的 chart,下面就来实践这个主题. 创建 chart 执行 helm create mychart 的 ...

  4. DX11 Without DirectX SDK--01 DirectX11初始化

    回到 DirectX11--使用Windows SDK来进行开发 由于个人觉得龙书里面第4章提供的Direct3D 初始化项目封装得比较好,而且DirectX SDK Samples里面的初始化程序过 ...

  5. Maven安装和使用

    一.安   装 1.解压好后,添加系统环境变量 变量名:MAVEN_HOME 属性值:D:\apache-maven-3.3.3  //也就是解压的路径 path中添加:%MAVEN_HOME%\bi ...

  6. echart css样式弄了几个月了,样式一直都没有好好解决,好激动

    legend 图例,每个图表最多仅有一个图例.try this » 名称 默认值 描述 {string} orient 'horizontal' 布局方式,默认为水平布局,可选为:'horizonta ...

  7. union 的两个用处

    1 节约内存: 这一功能可以参考我的其它博文: https://i.cnblogs.com/EditPosts.aspx?postid=8545190&update=1 2 测试机器大小端: ...

  8. Redis in Python:HyperLogLog(pfadd、pfcount、pfmerge)

    redis HyperLogLog 可以接受多个元素作为输入,并给出输入元素的基数估算值. 基数:集合中不同元素的数量.比如 [foo', 'bar', 'foobar', 'bar', 'test' ...

  9. linux下安装python3.6.4

    想在阿里云端装一个 python36,因为自带的python2有点老 ,(centos系统) 当然你如果选择的乌班图系统的话就自带了python3,就不用看了 于是查找资料,但是一步一步的来总是不行, ...

  10. indexer.go

    package) ; , ].DocId,:],)) :],) :], , ] ; ];]--],]) , ) )) )-b+b*d/avgDocLength)) , ;].locations[ind ...