예제 #1
0
파일: test.py 프로젝트: tbohlen/human-gibbs
    def test_sanity_checks(self):
        # test change in mean
        result0 = analysis.discrete_trunc_t_logpdf([0,1], 1, range(2))
        result1 = analysis.discrete_trunc_t_logpdf([0,1], 1, range(2), loc=1)

        assert_approx_equal(result0[0], result1[1])
        assert_approx_equal(result0[1], result1[0])

        # test change in scale
        result2 = analysis.discrete_trunc_t_logpdf([0,1], 1, range(2), scale=1)
        result3 = analysis.discrete_trunc_t_logpdf([0,1], 1, range(2), scale=10)

        self.assertTrue(result2[0] > result3[0])
        self.assertTrue(result2[1] < result3[1])
예제 #2
0
파일: test.py 프로젝트: tbohlen/human-gibbs
    def test_normalization(self):
        # set up
        x = arange(12).reshape((3,4))
        result = analysis.discrete_trunc_t_logpdf(x, 4, range(12))

        # make sure normalized
        assert_approx_equal(sum(exp(result)), 1)
예제 #3
0
파일: test.py 프로젝트: tbohlen/human-gibbs
    def test_default_loc_and_scale(self):
        # set up test
        x = eye(2)
        result = analysis.discrete_trunc_t_logpdf(x, 1, range(2))
        
        # check that the values that should be the same are the same
        assert_approx_equal(result[0,0], result[1,1])
        assert_approx_equal(result[0,1], result[1,0])

        # check that values that should be larger are larger
        self.assertTrue(result[0,0] < result[1,0])

        # check that the is properly normalized
        assert_approx_equal(exp(result[0,0]) + exp(result[1,0]), 1)
예제 #4
0
파일: test.py 프로젝트: tbohlen/human-gibbs
    def test_array_scale(self):
        result = analysis.discrete_trunc_t_logpdf([0,0], 1, range(2), scale=[1,10])

        self.assertTrue(result[0] > result[1])
예제 #5
0
파일: test.py 프로젝트: tbohlen/human-gibbs
    def test_array_mean(self):
        result = analysis.discrete_trunc_t_logpdf([0,1], 1, range(2), loc=[0,1])

        assert_approx_equal(result[0], result[1])