painyeph / fishersexacttest Goto Github PK
View Code? Open in Web Editor NEWA fast, precise, pure Python implementation of Fisher's exact test
A fast, precise, pure Python implementation of Fisher's exact test
Dear painyeph
I found that for very few contingency tables, your implementation fails:
a, b, c, d = (2, 3, 0, 2)
fisher.test1t(a, b, c, d) #0.5238095238095246
scipy.stats.fisher_exact([[a, b], [c, d]], 'two-sided')[1] # 1.0
Hey painyeph
Thanks a lot for your great work!
I lazily wanted to see how much faster your tool would be using numba / Cython. The result is quite impressive, see my repo!
https://github.com/MrTomRod/fast-fisher
a | b | c | d | test type | scipy | f_python | f_compiled |
---|---|---|---|---|---|---|---|
8 | 2 | 1 | 5 | left-tailed | 130 us | 3 us | 1 us |
8 | 2 | 1 | 5 | right-tailed | 134 us | 3 us | 0 us |
8 | 2 | 1 | 5 | two-tailed | 884 us | 6 us | 1 us |
100 | 1000 | 10000 | 100000 | left-tailed | 153 us | 57 us | 5 us |
100 | 1000 | 10000 | 100000 | right-tailed | 218 us | 73 us | 6 us |
100 | 1000 | 10000 | 100000 | two-tailed | 174 us | 130 us | 10 us |
10000 | 100 | 1000 | 100000 | left-tailed | 955 us | 8 us | 1 us |
10000 | 100 | 1000 | 100000 | right-tailed | 135 us | 7 us | 1 us |
10000 | 100 | 1000 | 100000 | two-tailed | 62821 us | 753 us | 53 us |
10000 | 10000 | 10000 | 10000 | left-tailed | 900 us | 323 us | 26 us |
10000 | 10000 | 10000 | 10000 | right-tailed | 912 us | 329 us | 27 us |
10000 | 10000 | 10000 | 10000 | two-tailed | 172 us | 679 us | 53 us |
f_python
is your version, f_compiled
is mine.
I added the MIT licence. Hope that's ok for you.
The only downside is that numba is added as a dependency.
The newest version is a Cython module with almost the same performance as numba. The only dependency is now that python-devel
must be installed.
Shall I make a pull request?
Best,
MrTomRod
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.