def test_prob_no_birth_eq(self):

        n = 2
        T = 1.2
        birth = 2.0
        death = 2.0
        self.assertAlmostEqual(
            birthdeath.prob_no_birth(n, T, birth, death*.9999),
            birthdeath.prob_no_birth(n, T, birth, death),
            places=4)
Exemple #2
0
    def test_prob_no_birth_eq(self):

        n = 2
        T = 1.2
        birth = 2.0
        death = 2.0
        self.assertAlmostEqual(birthdeath.prob_no_birth(
            n, T, birth, death * .9999),
                               birthdeath.prob_no_birth(n, T, birth, death),
                               places=4)
Exemple #3
0
    def test_sample_birth(self):

        prep_dir("test/output/birth_death_sample")

        n = 1
        T = 1.0
        birth = 2.0
        death = 0.5

        tic("sampling")
        samples = [
            birthdeath.sample_birth_wait_time(n, T, birth, death)
            for i in xrange(10000)
        ]
        toc()

        tic("samplingC")
        samples2 = [
            spidir.sampleBirthWaitTime1(T, birth, death) for i in xrange(10000)
        ]
        toc()

        cond = 1.0 - birthdeath.prob_no_birth(n, T, birth, death)

        x, y2 = distrib(samples, 20)
        x2, y3 = distrib(samples2, 20)
        y = [
            birthdeath.birth_wait_time(i, n, T, birth, death) / cond for i in x
        ]

        rp.plot(x, y, t="l", xlab="", ylab="")
        rp.lines(x, y2, col="red")
        rp.lines(x2, y3, col="blue")
        raw_input()
Exemple #4
0
    def test_sample_birth(self):

        prep_dir("test/output/birth_death_sample")

        n = 1
        T = 1.0
        birth = 2.0
        death = 0.5

        tic("sampling")
        samples = [birthdeath.sample_birth_wait_time(n, T, birth, death)
                   for i in xrange(10000)]        
        toc()

        tic("samplingC")
        samples2 = [spidir.sampleBirthWaitTime1(T, birth, death)
                   for i in xrange(10000)]        
        toc()

        cond = 1.0 - birthdeath.prob_no_birth(n, T, birth, death)

        x, y2 = distrib(samples, 20)
        x2, y3 = distrib(samples2, 20)
        y = [birthdeath.birth_wait_time(i, n, T, birth, death) / cond
              for i in x]

        rp.plot(x, y, t="l", xlab="", ylab="")
        rp.lines(x, y2, col="red")
        rp.lines(x2, y3, col="blue")
        raw_input()