快速费希尔精确检验
fisher的Python项目详细描述
费希尔精确检验
简单、快速地实现Fisher’s exact test。。例如,对于下表:
o | Having the property | Not having the property |
---|---|---|
Selected | 12 | 5 |
Not selected | 29 | 2 |
也许我们感兴趣的是,在选择组和非选择组中是否存在任何性质的差异,然后我们可以做fisher精确检验。
安装
在此文件夹中
easy_install .
来自PYPI
easy_install fisher
或来自Github(欢迎投稿)
git clone git://github.com/brentp/fishers_exact_test.git
用法
fisher.pvalue()接受与2乘2列联表对应的4个值,返回一个具有左尾翼、右尾翼和两个尾翼p值属性的对象
>>> from fisher import pvalue >>> mat = [[12, 5], [29, 2]] >>> p = pvalue(12, 5, 29, 2) >>> p.left_tail, p.right_tail, p.two_tail # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS (0.04455473783507..., 0.994525206021..., 0.0802685520741...)
基准
一个简单的基准,调用fisher精确测试1000次(inscripts/rfisher.py):
calling python fisher... iterations/sec: 3000.62526381 calling rpy fisher... iterations/sec: 289.225902364 calling R directly... iterations/sec: 244.36542276
所以cython fisher的速度是rpy或r版本的10倍。