def test_mcmc_done(self): r = Relationship(utils.straight_line, TEST_X, TEST_Y, bounds=((0, 10), (-1, 1))) r.mcmc(n_burn=10, n_samples=10, progress=False, walkers=5) assert_equal(r.mcmc_done, True)
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)
def test_mcmc(self): r = Relationship(utils.straight_line, TEST_X, TEST_Y, bounds=((0, 10), (-1, 1))) r.mcmc(n_burn=10, n_samples=10, progress=False, walkers=5) assert_equal(isinstance(r.variables[0], Distribution), True) assert_equal(isinstance(r.variables[1], Distribution), True) assert_equal(r.variables[0].size, 50) assert_equal(r.variables[1].size, 50) assert_equal(r.variables[0].min > 0, True) assert_equal(r.variables[0].max < 10, True) assert_equal(r.variables[1].min > -1, True) assert_equal(r.variables[1].max < 1, True)
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)