Exemple #1
0
 def test_variable_modes_no_sampling(self):
     r = Relationship(utils.straight_line,
                      TEST_X,
                      TEST_Y,
                      bounds=((0, 10), (-1, 1)))
     r.max_likelihood('diff_evo')
     assert_equal(np.allclose(r.variable_modes, [1, 0], atol=1.5), True)
Exemple #2
0
 def test_variable_modes(self):
     r = Relationship(utils.straight_line,
                      TEST_X,
                      TEST_Y,
                      bounds=((0, 10), (-1, 1)))
     r.max_likelihood('diff_evo')
     r.mcmc(n_burn=10, n_samples=10, progress=False, walkers=5)
     assert_equal(np.allclose(r.variable_modes, [1, 0], atol=1.5), True)
Exemple #3
0
 def test_max_likelihood(self):
     r = Relationship(utils.straight_line,
                      TEST_X,
                      TEST_Y,
                      bounds=((0, 10), (-1, 1)))
     r.max_likelihood('diff_evo')
     assert_equal(isinstance(r.variables[0], Distribution), True)
     assert_equal(isinstance(r.variables[1], Distribution), True)
     assert_equal(np.isclose(r.variables[0].n, 1, atol=0.75), True)
     assert_equal(np.isclose(r.variables[1].n, 0, atol=0.75), True)
Exemple #4
0
 def test_correlation_matrix(self):
     """
     Test correlation_matrix function.
     """
     TEST_Y = []
     for i in np.arange(1, 9, 1):
         TEST_Y.append(
             Distribution(scipy.stats.norm.rvs(loc=i, scale=0.5, size=200)))
     TEST_X = np.arange(1, 9, 1)
     test_rel = Relationship(utils.straight_line, TEST_X, TEST_Y)
     test_rel.max_likelihood('mini')
     test_rel.mcmc(n_burn=10, n_samples=10)
     actual_matrix = utils.correlation_matrix(test_rel)
     assert_equal(actual_matrix.shape, (2, 2))
     assert_almost_equal(actual_matrix[1, 0], actual_matrix[0, 1])
     assert_almost_equal(actual_matrix[0, 0], 1.0)
     assert_almost_equal(actual_matrix[1, 1], 1.0)
     assert_equal(test_rel.mcmc_done, True)