def test_correlation(self):
     fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__")
     values = [random.random() for i in range(0, 100)]
     values = [[x, x + random.random() / 2] for x in values]
     tbl = TableFormula(["x", "y"], values)
     cov = tbl.covariance()
     assert len(cov.values) == 2
     assert len(cov.header) == 3
     assert cov[1, 1] == cov[0, 2]
     cor = tbl.correlation()
     assert len(cor.values) == 2
     assert len(cor.header) == 3
     assert cov[1, 1] == cov[0, 2]
     assert abs(cor[0, 1] - cor[1, 2]) < 1e-5
     assert abs(1 - cor[1, 2]) < 1e-5
 def test_correlation(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     values = [random.random() for i in range(0, 100)]
     values = [[x, x + random.random() / 2] for x in values]
     tbl = TableFormula(["x", "y"], values)
     cov = tbl.covariance()
     assert len(cov.values) == 2
     assert len(cov.header) == 3
     assert cov[1, 1] == cov[0, 2]
     cor = tbl.correlation()
     assert len(cor.values) == 2
     assert len(cor.header) == 3
     assert cov[1, 1] == cov[0, 2]
     assert abs(cor[0, 1] - cor[1, 2]) < 1e-5
     assert abs(1 - cor[1, 2]) < 1e-5
 def test_correlation(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     values = [random.random() for i in range(0, 100)]
     values = [[x, x + random.random() / 2] for x in values]
     tbl = TableFormula(["x", "y"], values)
     cov = tbl.covariance()
     assert len(cov.values) == 2
     assert len(cov.header) == 3
     assert cov[1, 1] == cov[0, 2]
     cor = tbl.correlation()
     assert len(cor.values) == 2
     assert len(cor.header) == 3
     assert cov[1, 1] == cov[0, 2]
     assert abs(cor[0, 1] - cor[1, 2]) < 1e-5
     assert abs(1 - cor[1, 2]) < 1e-5
     assert tbl.shape is not None
     tbl[0, 0] = 0.
     tbl[0, 1] = 0.
     row = tbl[0]
     assert row is not None
     assert tbl[0, 0] == 0
     row = tbl[:1]
     assert row is not None
     row = tbl[[0]]
     assert row is not None
     tbl2 = None
     assert tbl != tbl2
     tbl2 = tbl
     assert tbl == tbl2
     res = tbl.avg_std(lambda r: r['x'])
     self.assertIsInstance(res, tuple)
     cor = tbl.correlation_col('x', 'y')
     self.assertIsInstance(cor, float)
     cor = tbl.correlation_row(0, 1)
     self.assertIsInstance(cor, float)
     cor = tbl.covariance_row(0, 1)
     self.assertIsInstance(cor, float)
     cor = tbl.correlation()
     self.assertEqual(cor.shape, (2, 3))
     cor = tbl.correlation(useBootstrap=True)
     self.assertEqual(cor.shape, (2, 3))