Ejemplo n.º 1
0
def get_interval_z_prob(low_z,high_z):
    """Get the probability of a range of z scores  
    """
    if low_z > high_z:
        raise ValueError(\
          "lower z value low_z must be lower than upper bound z value high_z.  Were parameters reversed?")
    #The low z represents a lower deviation from the mean,
    # and so will produce the higher probability
    high_prob = z_high(low_z)
    low_prob = z_high(high_z)
    interval_z_prob = high_prob - low_prob
    return interval_z_prob
Ejemplo n.º 2
0
def z_tailed_prob(z, tails):
    """Returns appropriate p-value for given z, depending on tails."""
    if tails == 'high':
        return z_high(z)
    elif tails == 'low':
        return z_low(z)
    else:
        return zprob(z)
Ejemplo n.º 3
0
 def test_z_high(self):
     """z_high should match R's pnorm(lower.tail=FALSE) function"""
     
     negprobs = [
         0.5000000, 0.5039894, 0.5398278, 0.6914625, 0.8413447,
         0.9772499, 0.9999997, 1.0000000, 1.0000000, 1.0000000,
         1.0000000, 1.0000000,
         ]
     probs = [
         5.000000e-01, 4.960106e-01, 4.601722e-01, 3.085375e-01,
         1.586553e-01, 2.275013e-02, 2.866516e-07, 7.619853e-24,
         2.753624e-89, 4.906714e-198, 0.000000e+00, 0.000000e+00]
     
     for z, p in zip(self.values, probs):
         self.assertFloatEqual(z_high(z), p)
     for z, p in zip(self.negvalues, negprobs):
         self.assertFloatEqual(z_high(z), p)