以前にどこかにも書いたけど,
$ pip install FisherExact
で
>>> from FisherExact import fisher_exact
>>> fisher_exact([[1,3],[4,2]])
はできるんだけど。2 x 2 より大きい分割表を指定すると segmentation fault で落ちる
以下のようにすれば,R を呼んで,結果は出る
$ pip install rpy2
>>> import numpy as np
>>> import rpy2.robjects.numpy2ri
>>> from rpy2.robjects.packages import importr
>>> rpy2.robjects.numpy2ri.activate()
>>> stats = importr('stats')
>>> m = np.array([[4,4],[4,5],[10,6]]) # 対象とする分割表の定義
>>> res = stats.fisher_test(m) # fisher.test 起動
>>> print('p-value: {}'.format(res[0][0]))
やっぱ,Python は,ヤダナ