
There is one difficulty with the two-sided Fisher exact test. To calculate a p-value for the left-sided test, you take the cdf of the hypergeometric distribution for the observed value of the test statistica. I you want to calculate a p-value for the right-sided test, then you just take cdf complement for the observed value of the test statistica. But for a two-sided test, well, say that the observed value of the test statistica is n. Then you should sum the pdf over all k such that pdf(k) <= pdf(n). This means summing over both tails. And since the distribution is not symmetric, you can not just sum over one tail and multiply by 2, as you do with the 2-sided t-test. I don't see how to do that in a clean way using the current statistical distributions API. (Am I missing something?) Maybe some extension to the statistical distributions API is needed. Something like cdf(symmetric(dist,x)) for the sum/integral of pdf(dist,y) over all y such that pdf(dist,y) <= pdf(dist,x). --Johan Råde