Ejemplo n.º 1
0
def esty_ci(counts, **args):
    """Esty's CI for (1-m).
    
    counts: Vector of counts (NOT the sample)

    Esty's CI is defined in 
    Esty WW (1983) A Normal limit law for a nonparametric estimator of the
    coverage of a random sample. Ann Statist 11: 905-912.

    n1 / n  +/- z * square-root(W);

    where
    n1 = number of species observed once in n samples;
    n = sample size;
    z = a constant that depends on the targeted confidence and based on
        the Normal distribution. For a 95% CI, z=1.959963985;
    n2 = number of species observed twice in n samples;
    W = [ n1*(n - n1)  +  2*n*n2 ] / (n**3).

    Note: for other confidence levels we first need the appropriate z,
          Not yet hooked up to CLI.

    Returns: (upper bound, lower bound)
    """
    
    n1 = singles(counts)
    n2 = doubles(counts)
    n  = counts.sum()
    z  = 1.959963985
    W  = (n1*(n-n1) + 2*n*n2)/(n**3)

    return  n1/n + z*sqrt(W), n1/n - z*sqrt(W) 
Ejemplo n.º 2
0
 def test_singles(self):
     """singles should return correct # of singles"""
     self.assertEqual(singles(self.TestData), 3)
     self.assertEqual(singles(array([0,3,4])), 0)
     self.assertEqual(singles(array([1])), 1)