def test_cdf_bmc_simple(self): # test cdf mrca BMC stree = treelib.parse_newick("((A:1000, B:1000):500, C:1500);") n = 1000 gene_counts = dict.fromkeys(stree.leaf_names(), 1) T = 2000 self.assertAlmostEqual( exp(coal.cdf_mrca_bounded_multicoal(gene_counts, T, stree, n)), 0.27719726132)
def test_cdf_bmc(self): # test cdf mrca BMC stree = treelib.parse_newick( "((A:1000, B:1000):500, (C:700, D:700):800);") n = 1000 gene_counts = dict.fromkeys(stree.leaf_names(), 1) T = 2000 p = exp(coal.cdf_mrca_bounded_multicoal(gene_counts, T, stree, n)) nsamples = 5000 c = 0 for i in xrange(nsamples): tree, recon = coal.sample_multicoal_tree(stree, n) if treelib.get_tree_timestamps(tree)[tree.root] < T: c += 1 p2 = c / float(nsamples) fequal(p, p2, .05)