Пример #1
0
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
 def test_log_one_minus_small(self):
     """log_one_minus_x should return -x if x is small"""
     self.assertFloatEqualRel(log_one_minus(1e-30), 1e-30)
Пример #3
0
 def test_log_one_minus_large(self):
     """log_one_minus_x should return math.log(1-x) if x is large"""
     self.assertFloatEqual(log_one_minus(0.2), math.log(1-0.2))
Пример #4
0
def multiple_n(p_initial, p_final):
    """Returns number of comparisons such that p_initial maps to p_final.
    
    WARNING: not very accurate when p_final is very close to 1.
    """
    return log_one_minus(p_final)/log_one_minus(p_initial)
Пример #5
0
 def test_log_one_minus_small(self):
     """log_one_minus_x should return -x if x is small"""
     self.assertFloatEqualRel(log_one_minus(1e-30), 1e-30)
Пример #6
0
 def test_log_one_minus_large(self):
     """log_one_minus_x should return math.log(1-x) if x is large"""
     self.assertFloatEqual(log_one_minus(0.2), math.log(1 - 0.2))