#! usr/bin/perl use warnings; use strict; use Test; # use a BEGIN block so we print our plan before MyModule is loaded BEGIN { plan tests => 40, todo => [], } use lib "$ENV{HOME}/Desktop/perl/lib"; use Statistics::FET; use Statistics::FishersExactTest; print "***888 - Original Statistics::FET - 888***\n"; ## two tailed print "\n***\ntwotailed a-b-c-d\n***\n"; ok( Statistics::FET::fishers_exact(100 , 345 , 150 , 450, 'true', ), qr/^0.378973935/ ); ok( Statistics::FET::fishers_exact(150 , 345 , 150 , 500, 'true', ), qr/^0.006634280/ ); ok( Statistics::FET::fishers_exact(110 , 345 , 250 , 500, 'true', ), qr/^0.000737131/ ); ok( Statistics::FET::fishers_exact(11 , 34 , 25 , 50, 'true', ), qr/^0.410784065/ ); ok( Statistics::FET::fishers_exact(11 , 34 , 25 , 60, 'true', ), qr/^0.680962824/ ); print "\n***\ntwotailed (b-a-d-c)\n***\n"; ok( Statistics::FET::fishers_exact(345 , 100 , 450 , 150, 'true', ), qr/^0.378973935/ ); ok( Statistics::FET::fishers_exact(345 , 150 , 500 , 150, 'true', ), qr/^0.006634280/ ); ok( Statistics::FET::fishers_exact(345 , 110 , 500 , 250, 'true', ), qr/^0.000737131/ ); ok( Statistics::FET::fishers_exact(34 , 11 , 50 , 25, 'true', ), qr/^0.410784065/ ); ok( Statistics::FET::fishers_exact(34 , 11 , 60 , 25, 'true', ), qr/^0.680962824/ ); ## one tailed ## - return 'Right' tail print "\n***\nright tailed (a-b-c-d)\n***\n"; ok( Statistics::FET::fishers_exact(100 , 345 , 150 , 450, ), qr/^0.846286197/ ); ok( Statistics::FET::fishers_exact(150 , 345 , 150 , 500, ), qr/^0.003674851/ ); ok( Statistics::FET::fishers_exact(110 , 345 , 250 , 500, ), qr/^0.999730774/ ); ok( Statistics::FET::fishers_exact(11 , 34 , 25 , 50, ), qr/^0.892322547/ ); ok( Statistics::FET::fishers_exact(11 , 34 , 25 , 60, ), qr/^0.789358818/ ); ## one tailed ## - return 'left' tail print "\n***\nleft tailed b-a-c-d\n***\n"; ok( Statistics::FET::fishers_exact(345 , 100 , 450 , 150, ), qr/^0.191219881/ ); ok( Statistics::FET::fishers_exact(345 , 150 , 500 , 150, ), qr/^0.997565862/ ); ok( Statistics::FET::fishers_exact(345 , 110 , 500 , 250, ), qr/^0.000436655/ ); ok( Statistics::FET::fishers_exact(34 , 11 , 50 , 25, ), qr/^0.206057717/ ); ok( Statistics::FET::fishers_exact(34 , 11 , 60 , 25, ), qr/^0.349218359/ ); print "***888 - bugfixed Statistics::FishersExactTest - 888***\n"; ## two tailed print "\n***\ntwotailed a-b-c-d\n***\n"; ok( Statistics::FishersExactTest::fishers_exact(100 , 345 , 150 , 450, 'true', ), qr/^0.378973935/ ); ok( Statistics::FishersExactTest::fishers_exact(150 , 345 , 150 , 500, 'true', ), qr/^0.006634280/ ); ok( Statistics::FishersExactTest::fishers_exact(110 , 345 , 250 , 500, 'true', ), qr/^0.000737131/ ); ok( Statistics::FishersExactTest::fishers_exact(11 , 34 , 25 , 50, 'true', ), qr/^0.410784065/ ); ok( Statistics::FishersExactTest::fishers_exact(11 , 34 , 25 , 60, 'true', ), qr/^0.680962824/ ); print "\n***\ntwotailed (b-a-d-c)\n***\n"; ok( Statistics::FishersExactTest::fishers_exact(345 , 100 , 450 , 150, 'true', ), qr/^0.378973935/ ); ok( Statistics::FishersExactTest::fishers_exact(345 , 150 , 500 , 150, 'true', ), qr/^0.006634280/ ); ok( Statistics::FishersExactTest::fishers_exact(345 , 110 , 500 , 250, 'true', ), qr/^0.000737131/ ); ok( Statistics::FishersExactTest::fishers_exact(34 , 11 , 50 , 25, 'true', ), qr/^0.410784065/ ); ok( Statistics::FishersExactTest::fishers_exact(34 , 11 , 60 , 25, 'true', ), qr/^0.680962824/ ); ## one tailed ## - return 'Right' tail print "\n***\nright tailed (a-b-c-d)\n***\n"; ok( Statistics::FishersExactTest::fishers_exact(100 , 345 , 150 , 450, ), qr/^0.846286197/ ); ok( Statistics::FishersExactTest::fishers_exact(150 , 345 , 150 , 500, ), qr/^0.003674851/ ); ok( Statistics::FishersExactTest::fishers_exact(110 , 345 , 250 , 500, ), qr/^0.999730774/ ); ok( Statistics::FishersExactTest::fishers_exact(11 , 34 , 25 , 50, ), qr/^0.892322547/ ); ok( Statistics::FishersExactTest::fishers_exact(11 , 34 , 25 , 60, ), qr/^0.789358818/ ); ## one tailed ## - return 'left' tail print "\n***\nleft tailed b-a-c-d\n***\n"; ok( Statistics::FishersExactTest::fishers_exact(345 , 100 , 450 , 150, ), qr/^0.191219881/ ); ok( Statistics::FishersExactTest::fishers_exact(345 , 150 , 500 , 150, ), qr/^0.997565862/ ); ok( Statistics::FishersExactTest::fishers_exact(345 , 110 , 500 , 250, ), qr/^0.000436655/ ); ok( Statistics::FishersExactTest::fishers_exact(34 , 11 , 50 , 25, ), qr/^0.206057717/ ); ok( Statistics::FishersExactTest::fishers_exact(34 , 11 , 60 , 25, ), qr/^0.349218359/ ); __DATA__ Fisher's Exact Test http://www.langsrud.com/fisher.htm # 1 + 6 + 11 + 16 ------------------------------------------ TABLE = [ 100 , 345 , 150 , 450 ] Left : p-value = 0.191219881514147 Right : p-value = 0.8462861978699979 2-Tail : p-value = 0.37897393517037725 # 2 + 7 + 12 + 17 ------------------------------------------ TABLE = [ 150 , 345 , 150 , 500 ] Left : p-value = 0.9975658620326552 Right : p-value = 0.0036748512483445626 2-Tail : p-value = 0.006634280583017804 # 3 + 8 + 13 + 18 ------------------------------------------ TABLE = [ 110 , 345 , 250 , 500 ] Left : p-value = 0.00043665577543502157 Right : p-value = 0.9997307748788292 2-Tail : p-value = 0.0007371317326469082 # 4 + 9 + 14 + 19 ------------------------------------------ TABLE = [ 11 , 34 , 25 , 50 ] Left : p-value = 0.20605771741014312 Right : p-value = 0.8923225471119328 2-Tail : p-value = 0.41078406593596795 # 5 + 10 + 15 + 20 ------------------------------------------ TABLE = [ 11 , 34 , 25 , 60 ] Left : p-value = 0.34921835927372824 Right : p-value = 0.7893588188856397 2-Tail : p-value = 0.6809628247605259 ------------------------------------------