http://qs1969.pair.com?node_id=482095

Hmm 1%1?

```C:\ghc\ghc-6.4\code>ghc --make FET.hs -o FET.exe
Chasing modules from: FET.hs
Compiling FishersExactTest ( ./FishersExactTest.hs, ./FishersExactTest
+.o )
Compiling Main             ( FET.hs, FET.o )

C:\ghc\ghc-6.4\code>FET
989 9400 43400 2400
^Z
1%1
C:\ghc\ghc-6.4\code>echo 989 9400 43400 2400 | FET
1%1

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.
• Comment on Re^10: Algorithm for cancelling common factors between two lists of multiplicands

Replies are listed 'Best First'.
Re^11: Algorithm for cancelling common factors between two lists of multiplicands
by tmoertel (Chaplain) on Aug 09, 2005 at 02:02 UTC
You entered a 4x1 matrix, and so that's why you got an answer of 1. (The code works on general matricies and does not assume the 2x2 case.) Enter the data as a 2x2 matrix to get the result you expect:
```\$ ./fet
989 9400
43400 2400
^D

... tons of output ...

Cheers,
Tom

How do I get that output reduced to a real in scientific format?

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.
How do I get that output reduced to a real in scientific format?
If you want arbitrary precision, the safest bet is to extract the digits yourself:
```module ScientificFormat (sciformat) where

import Ratio

-- return prec+1 digits because I don't round

sciformat prec r =
sign ++ digits ++ "e" ++ show exp
where
(ds, exp) = tosci (abs numer) (denominator r) 0
numer     = numerator r
sign      = if signum numer < 0 then "-" else "+"
digits    = show (head ds') ++ "." ++ concatMap show (tail ds')
ds'       = take (prec+1) (ds ++ repeat 0)

tosci 0     _     _   = ([0], 0)
tosci numer denom exp =
case numer `div` denom of
0           -> tosci (10 * numer) denom (exp-1)
x | x >= 10 -> tosci numer (10*denom) (exp+1)
_           -> (digits numer denom, exp)

digits n d =
let (q,r) = n `quotRem` d in q : digits (10*r) d
And:
```module Main (main) where
import FishersExactTest
import ScientificFormat
main = interact \$ sciformat 60 . pCutoff . map (map read . words) . li
+nes
```[thor@arinmir fishers-exact-test]\$ time ./fet < ex1.dat