0

I am referring to the Wikipedia example here (https://en.wikipedia.org/wiki/Fisher%27s_exact_test) which shows:

enter image description here

My Question is how is this 0.001346 figure reached? After reading, I appreciate that the 10! is the product but when times or summing, I cannot produce this figure in my code (I am using PHP).

private function processProducts($products){
  $prods = $this->prods;

    $times = 0;

    foreach ($products as $p){
        if (!empty($prods[$p])){
            $use = $prods[$p];
   } else {
    // Product = 10 = 10*9*8*7*6*5*4*3*2*1
    $use = array_product(range(1,$p));
    $prods[$p] = $use;
        }

        echo $p.'--'.$use.'<br>';

        if ($times == 0){
    $times = $use;
   } elseif ($p > 0) {
            $times = $times * $use;
        }
    }

    $this->prods = $prods;

return $times;
}

echo $this->processProducts(array(10,14,12,12)) / $this->processProducts(array(1,9,11,3,24));

Antony
  • 1
  • 1
  • The first question to ask is _why_ it should be calculated when it's not very accurate. That has been discussed in [these](https://www.zotero.org/groups/2199991/feh/tags/fishers-exact-test/library) papers and much discussed on this site. – Frank Harrell May 21 '21 at 12:05
  • I have tried to find a good example (for a non math person) for Barnards instead but didn't find one. Do you have an example? – Antony May 21 '21 at 12:48

1 Answers1

0

After referencing https://en.wikipedia.org/wiki/Lady_tasting_tea which I found through a Youtube video, you can get there using this formula

private function curlyBrackets($top,$bottom){
    $t1 = array_product(range(1,$top));
    $t2 = array_product(range(1,$bottom));
    $t3 = array_product(range(1,$top - $bottom));

return $t1 / ($t2 * $t3);
}

Triggered by this:

`echo ($this->curlyBrackets(10,1) * $this->curlyBrackets(14,11)) / $this->curlyBrackets(24,12);`
Antony
  • 1
  • 1