Skip to content

Fast implementation of Fisher exact test (hypergeometric test) in Matlab.

Notifications You must be signed in to change notification settings

aallahyar/Fast_Fisher_Exact_Test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 

Repository files navigation

Fast Fisher Exact Test

Fast implementation of Fisher exact test (hypergeometric test) in Matlab. This function requires no toolbox to be installed (tested on Matlab v2016b).

Description:

One can use fisher exact test to calculate degree of association between two groups. The following is a contingency table for association between being a man (or woman) and wearing hat.

Men Women Row Total
Have hat a b a+b
No hat c d c+d
Column Total a + c b + d N

P-value of such a table can be calculated by:

FisherExactTest

Speed

My tests showed that this implementation is at least 20 times faster than current implementation in Matlab (ver 2016b).

Citation

This code is heavily inspired by an implementation by Jia Meng: MatWorks FileExchange

Usage example

This example calculates "left tail" (i.e. mutual exclusivity) p-value as well as "right tail" (i.e. cooperation) p-value:

[pval_left_tail, pval_right_tail] = FastFisherExactTest(a, b, c, d)

Known Bugs

In my tests, I could identify 1e-10 difference between my implementation and Matlab. I think it is due to round-off errors. A script is provided in "testcode.m" to compare results with Matlab.

About

Fast implementation of Fisher exact test (hypergeometric test) in Matlab.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages