def test_cdf_mrca2(self): n = 1000 k = 6 step = 10 x = list(frange(0, 5000, step)) y = [coal.prob_mrca(i, k, n) * step for i in x] y2 = cumsum(y) y3 = [coal.cdf_mrca(t, k, n) for t in x] y4 = [coal.prob_coal_counts(k, 1, t, n) for t in x] fequals(y2, y3, eabs=.01) fequals(y3, y4)
def test_cdf_mrca(self): outdir = 'test/tmp/test_coal/Coal_test_cdf_mrca/' make_clean_dir(outdir) n = 1000 k = 6 step = 10 x = list(frange(0, 5000, step)) y = [coal.prob_mrca(i, k, n) * step for i in x] y2 = cumsum(y) y3 = [coal.cdf_mrca(t, k, n) for t in x] p = Gnuplot() p.enableOutput(False) p.plot(x, y2, style="lines") p.plot(x, y3, style="lines") p.enableOutput(True) p.save(outdir + 'plot.png') eq_sample_pdf(x, lambda t: coal.cdf_mrca(t, k, n), 40)
def test_coal_counts(self): b = 1 t = 1000.0 n = 1000 for a in xrange(1, 100): i = coal.prob_coal_counts(a, b, t, n) j = coal.cdf_mrca(t, a, n) fequal(i, j) for a in xrange(1, 10): i = sum(coal.prob_coal_counts(a, b, t, n) for b in xrange(1, a+1)) fequal(i, 1.0)