コード例 #1
0
ファイル: test.py プロジェクト: chungtseng/pycogent
def multiple_inverse(p_final, n):
    """Returns p_initial for desired p_final with n multiple comparisons.
    
    WARNING: multiple_inverse is not very reliable when p_final is very close
    to 1 (say, within 1e-4) since we then take the ratio of two very similar
    numbers.
    """
    return one_minus_exp(log_one_minus(p_final)/n)
コード例 #2
0
ファイル: test.py プロジェクト: chungtseng/pycogent
def multiple_comparisons(p, n):
    """Corrects P-value for n multiple comparisons.
    
    Calculates directly if p is large and n is small; resorts to logs
    otherwise to avoid rounding (1-p) to 1
    """
    if p > 1e-6:   #if p is large and n small, calculate directly
        return 1 - (1-p)**n
    else:
        return one_minus_exp(-n * p)
コード例 #3
0
ファイル: test_special.py プロジェクト: carze/clovr-base
 def test_one_minus_exp_small(self):
     """one_minus_exp_x should return -x if x is small"""
     self.assertFloatEqual(one_minus_exp(1e-30), -1e-30)
コード例 #4
0
ファイル: test_special.py プロジェクト: carze/clovr-base
 def test_one_minus_exp_large(self):
     """one_minus_exp_x should return 1 - math.exp(x) if x is large"""
     self.assertFloatEqual(one_minus_exp(0.2), 1-(math.exp(0.2)))
コード例 #5
0
ファイル: test_special.py プロジェクト: cxhernandez/pycogent
 def test_one_minus_exp_small(self):
     """one_minus_exp_x should return -x if x is small"""
     self.assertFloatEqual(one_minus_exp(1e-30), -1e-30)
コード例 #6
0
ファイル: test_special.py プロジェクト: cxhernandez/pycogent
 def test_one_minus_exp_large(self):
     """one_minus_exp_x should return 1 - math.exp(x) if x is large"""
     self.assertFloatEqual(one_minus_exp(0.2), 1 - (math.exp(0.2)))