Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Algorithm for cancelling common factors between two lists of multiplicands

by tlm (Prior)
on Aug 10, 2005 at 02:32 UTC ( #482495=note: print w/replies, xml ) Need Help??


in reply to Algorithm for cancelling common factors between two lists of multiplicands

From looking at the code you have posted I get the impression that you misunderstand the Fisher's Exact Test. What you are computing in your various implementations is only one term of the sum that makes up the FET statistic.

The definition of the FET statistic I'm referring to here is entirely standard (though there is some variability as to whether the one-sided or two-sided version of this sum is used).

The test says, if we assume the null hypothesis (independence between the two categorical variables), what is the probability of getting a sampling that is at least as far from the expected value (under the null hypothesis) as the actual data being tested; unless one of the cells is empty, this formulation entails computing a sum of terms. If you look at the code I posted, I don't compute a single ratio of factorials, but a whole sum of them. The value of this sum can be considerably larger than the value of a single term; in fact it can be 1, depending on the hypothesis being tested and the data at hand.

Update: Here's the relevant passage from the MathWorld page whose formula you cited elsewhere (my emphasis):

To compute the P-value of the test, the tables must then be ordered by some criterion that measures dependence, and those tables that represent equal or greater deviation from independence than the observed table are the ones whose probabilities are added together.

the lowliest monk

  • Comment on Re: Algorithm for cancelling common factors between two lists of multiplicands

Replies are listed 'Best First'.
Re^2: Algorithm for cancelling common factors between two lists of multiplicands
by BrowserUk (Pope) on Aug 10, 2005 at 10:13 UTC

    I'm am completely aware that all the other terms need to be calculated in order to determine whether the value is significant. I even mentioned this in 482056.

    And, I guess I could be misusing your code, but when I feed it these values 5 0 4 1, it produces the same output exactly as my "misguided" code. Funnily enough, for those values, it produces the same output as tmoertel's (apparently equally misguided) code.

    Is it only when given the larger set of test values 989 9400 43300 2400 that your special code does something extraordinarily clever that I'm to stupid to understand?

    $T->start( '[5 0 1 4]' ); print Fishers_Exact::fishers_exact( 5, 0, 1, 4 ); $T->stop( '[5 0 1 4]' ); $T->report; $T->start( '[989 9400 43300 2400]' ); print Fishers_Exact::fishers_exact( 989, 9400, 43300, 2400 ); $T->stop( '[989 9400 43300 2400]' ); $T->report; __END__ P:\test>FET-tlm.pl 0.02380952380952380952380952380 1 trial of [5 0 1 4] ( 917us total), 917us/trial 0.9999999999999999999999999999999999999999999999999999999999999999999 999999999999999999999999999999999999999999999999999999999999999999999 999999999999999999999999999999999999999999999999999999999999999999999 999999999999999999999999999999999999999999999999999999999999999999999 999999999999999999999999999999999999999999999999999999999999999999999 999999999999999999999999999999999999999999999999999999999999999999999 999999999999999999999999999999999999999999999999999999999999999999999 99999999999999999999999999999999952665545273822897512768877675 1 trial of [5 0 1 4] ( 917us total), 917us/trial 1 trial of [989 9400 43300 2400] ( 1.353s total), 1.353s/trial

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

      Of course our results will match in those rare cases in which the FET sum happens to contain only one term.

      Silence betokens consent

      Not necessarily ;-) .

      the lowliest monk

        Of course our results will match in those rare cases in which the FET sum happens to contain only one term.

        Care to try and explain that?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://482495]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2019-10-17 06:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?