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开发者_Go百科 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 :-)
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.
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.
精彩评论