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_prob_mrca(self): n = 1000 k = 50 x = [coal.sample_coal_times(k, n)[-1] for i in xrange(10000)] eq_sample_pdf(x, lambda t: coal.prob_mrca(t, k, n), 40)