예제 #1
0
    def test_expectation_single_factor(self):
        """ tests implementation of expect_log method against matlab version (single factor)
        """

        array_path = os.path.join(os.getcwd(), "tests/data/wnorm_a.mat")
        mat_contents = loadmat(file_name=array_path)
        result = mat_contents["result"]

        d = Dirichlet(values=mat_contents["A"])
        result_py = d.expectation_of_log(return_numpy=True)
        self.assertTrue(np.isclose(result, result_py).all())
예제 #2
0
    def test_expectation_multi_factor(self):
        """ tests implementation of expect_log method against matlab version (multi factor)
        """

        array_path = os.path.join(os.getcwd(), "tests/data/wnorm_b.mat")
        mat_contents = loadmat(file_name=array_path)
        result_1 = mat_contents["result_1"]
        result_2 = mat_contents["result_2"]

        d = Dirichlet(values=mat_contents["A"][0])
        result_py = d.expectation_of_log(return_numpy=True)

        self.assertTrue(
            np.isclose(result_1, result_py[0]).all()
            and np.isclose(result_2, result_py[1]).all())