Esempio n. 1
0
    def test_cdf_coal_cond_counts(self):

        # test coalescent pdf when conditioned on future lineage counts

        outdir = 'test/tmp/test_coal/Coal_test_cdf_coal_cond_counts/'
        make_clean_dir(outdir)

        a = 5
        for b in xrange(2, a):
            t = 500
            n = 1000
            p = Gnuplot()
            p.enableOutput(False)
            p.plotfunc(lambda x: coal.cdf_coal_cond_counts(
                x, a, b, t, n), 0, t, 10)

            # draw single coal samples using rejection sampling
            s = []
            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
                s.append(times[0])

            x2, y2 = stats.cdf(s)
            p.plot(x2, y2, style='lines')
            p.enableOutput(True)
            p.save(outdir + 'plot-%d.png' % b)

            eq_sample_pdf(
                x2, lambda x: coal.prob_coal_cond_counts(x, a, b, t, n), 40)
Esempio n. 2
0
    def test_prob_coal_cond_counts2(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(
                x, a, b, t, n), 40)
Esempio n. 3
0
    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)