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 :-)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With