Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficient Fisher's Exact Test in Java

I need a library/function/method to perform a Fisher's exact test in Java, and provide the right, left and two-tailed probabilities. Simple Googling shows a solution within the packages of Tassel, but the method inside simply applies the test steps with no optimization, and therefore it's extremely slow. Moreover, it uses int types everywhere and it's not really efficient for big contingency tables.

If you know any already written solution, help me :-)

like image 408
Federico Giorgi Avatar asked Jun 06 '11 14:06

Federico Giorgi


2 Answers

See if this helps: http://www.users.zetnet.co.uk/hopwood/tools/StatTests.java

The formula is quite simple. There's a very simple (two-tailed) implementation here: http://javanus.com/blogs/?p=51 (see the comment by Discretoboy for a much cleaner implementation)

You can also take a look at the test implementation in Java Statistical Classes.

like image 112
Aleadam Avatar answered Nov 20 '22 22:11

Aleadam


I use http://wordhoard.northwestern.edu/userman/javadoc/edu/northwestern/at/utils/math/statistics/FishersExactTest.html

A (very) brief test showed it to be similar in speed to the Java Statistical Classes (jsc) test mentioned above but it had the additional advantage of not giving me an illegal argument exception when my table included zero, which I believe is a legitimate case.

like image 20
PeterVermont Avatar answered Nov 20 '22 20:11

PeterVermont