Beispiel #1
0
    def test_Aitchison_transforms(self):
        """Test that alr_inv of alr is in fact the inverse
        of alr. Ditto for clr_inv and clr. Then test that clr
        transforms into hyperplane x1 + ... + xn=0."""
        length = len(self.x)
        for col in range(-1, length):
            y = alr_inv(self.x, col)
            assert allclose(self.x, alr(
                y,
                col)), ("Failed alr inverse test for col = " + str(col) + ".")

        z = dirichlet(self.x)
        y = clr(z)
        assert allclose(z, clr_inv(y)), "Failed clr inverse test."
        assert allclose(sum(y), 0), "Failed clr hyperplane test."
Beispiel #2
0
 def test_Aitchison_distance(self):
     x = self.d[0]
     y = self.d[1]
     assert allclose(aitchison_distance(x, y),
                     norm(clr(x) - clr(y))), "Failed distance test."