コード例 #1
0
ファイル: STAMP_test.py プロジェクト: mlangill/STAMP
	def testGTestYates(self):
		"""Verify computation of G-test with Yates' continuity correction"""
		from plugins.samples.statisticalTests.GTestYates import GTestYates
		gTestYates = GTestYates(preferences)
		
		# Ground truth obtained from Peter L. Hurd's R script (http://www.psych.ualberta.ca/~phurd/cruft/g.test.r)	
		oneSided, twoSided, note = gTestYates.hypothesisTest(table1[0], table1[1], table1[2], table1[3])	 
		self.assertEqual(oneSided, float('inf'))
		self.assertAlmostEqual(twoSided, 0.325502240010)
		
		oneSided, twoSided, note = gTestYates.hypothesisTest(table2[0], table2[1], table2[2], table2[3])	 
		self.assertEqual(oneSided, float('inf'))
		self.assertAlmostEqual(twoSided, 2.220446049e-16)
コード例 #2
0
    def testGTestYates(self):
        """Verify computation of G-test with Yates' continuity correction"""
        from plugins.samples.statisticalTests.GTestYates import GTestYates
        gTestYates = GTestYates(preferences)

        # Ground truth obtained from Peter L. Hurd's R script (http://www.psych.ualberta.ca/~phurd/cruft/g.test.r)
        oneSided, twoSided, note = gTestYates.hypothesisTest(
            table1[0], table1[1], table1[2], table1[3])
        self.assertEqual(oneSided, float('inf'))
        self.assertAlmostEqual(twoSided, 0.325502240010)

        oneSided, twoSided, note = gTestYates.hypothesisTest(
            table2[0], table2[1], table2[2], table2[3])
        self.assertEqual(oneSided, float('inf'))
        self.assertAlmostEqual(twoSided, 2.220446049e-16)
コード例 #3
0
ファイル: GTestFisher.py プロジェクト: mlangill/STAMP
class GTestFisher(AbstractSampleStatsTestPlugin):
	'''
	Perform G-test w/ Yates' correction or Fisher's exact test.
	'''
	
	def __init__(self, preferences):
		AbstractSampleStatsTestPlugin.__init__(self, preferences)
		self.name = 'G-test (w/ Yates\') + Fisher\'s'
		self.fishers = Fishers(self.preferences)
		self.gTestYates = GTestYates(self.preferences)
		
	def hypothesisTest(self, seq1, seq2, totalSeq1, totalSeq2):
		a = seq1
		b = seq2
		c = totalSeq1 - seq1
		d = totalSeq2 - seq2
		
		if a < 20 or b < 20 or c < 20 or d < 20:
			return self.fishers.hypothesisTest(seq1, seq2, totalSeq1, totalSeq2)
		else:
			return self.gTestYates.hypothesisTest(seq1, seq2, totalSeq1, totalSeq2)
コード例 #4
0
ファイル: GTestFisher.py プロジェクト: mlangill/STAMP
	def __init__(self, preferences):
		AbstractSampleStatsTestPlugin.__init__(self, preferences)
		self.name = 'G-test (w/ Yates\') + Fisher\'s'
		self.fishers = Fishers(self.preferences)
		self.gTestYates = GTestYates(self.preferences)