def test_prob_coal_cond_counts(self): # match against a simpler slower implementation a = 5 b = 3 t = 2000 n = 1000 for x in frange(0, 2000, 10): y = coal.prob_coal_cond_counts(x, a, b, t, n) y2 = coal.prob_coal_cond_counts_simple(x, a, b, t, n) self.assertAlmostEqual(y, y2)
def test_prob_coal_cond_counts_simple(self): # when we condition on b=1, it is the same as the bounded coal # PDF. # prob_coal_cond_counts is actually a more general version of # prob_bounded_coal outdir = 'test/tmp/test_coal/Coal_test_prob_coal_counys_simple/' make_clean_dir(outdir) a = 5 b = 1 t = 2000 n = 1000 p = Gnuplot() p.enableOutput(False) for x in frange(0, 2000, 10): y = coal.prob_coal_cond_counts_simple(x, a, b, t, n) y2 = coal.prob_bounded_coal(x, a, n, t) self.assertAlmostEqual(y, y2)
def test_prob_coal_cond_counts2_simple(self): # test coalescent pdf when conditioned on future lineage counts a = 5 for b in xrange(2, a): t = 500 n = 1000 # draw single coal samples using rejection sampling x2 = [] for i in xrange(1000): while True: times = coal.sample_coal_times(a, n) if times[a-b-1] < t and (b == 1 or times[a-b]) > t: break x2.append(times[0]) eq_sample_pdf( x2, lambda x: coal.prob_coal_cond_counts_simple( x, a, b, t, n), 40)