painyeph / FishersExactTest

A fast, precise, pure Python implementation of Fisher's exact test
12 stars 2 forks source link

Exceptions #2

Open MrTomRod opened 2 years ago

MrTomRod commented 2 years ago

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
MrTomRod commented 2 years ago

If I create 1000 contingency tables like this> int(random() * (range_max + 1)) for range_max in [10, 20, 40, 80, 160], I get fewer disagreements the higher range_max is:

10: 1.42 %
20: 0.84 %
40: 0.53 %
80: 0.29 %
160: 0.1 %

I.e., the higher the numbers, the more the two algorithms agree. Which one is more correct?