def test_compute_count_mat(self): """Testing computation of count matrix""" check_mat = np.array([[0, 7, 0], [0, 0, 6], [6, 0, 0]]) chain = np.array([0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1]) count_mat = est.compute_count_matrix(chain) self.assertTrue(np.allclose(count_mat, check_mat, atol=1e-5))
def test_compute_count_mat(self): """Testing computation of count matrix""" check_mat = np.array([[0, 7, 0], [0, 0, 6], [6, 0, 0]]) chain = np.array( [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1]) count_mat = est.compute_count_matrix(chain) self.assertTrue(np.allclose(count_mat, check_mat, atol=1e-5))
if args.plot: try: import matplotlib.pyplot as plt except ImportError: print 'No matplotlib available, import failed.' ##################################################################### # import data ##################################################################### data_importer = dataImp.SimpleDataImporter(args.iFile, i_delimiter=' ') ##################################################################### # k-means clustering ##################################################################### cluster = cl.kMeans(data_importer.get_data(), args.numCluster) cluster.discretize() ##################################################################### # estimation of transition matrix ##################################################################### chain = np.asarray(cluster.get_labels(), dtype=np.int64) count_mat = est.compute_count_matrix(chain, i_tau=1) trans_mat = est.estimate_transition_matrix(count_mat, 10000, 1e-3) is_reversible, check_mat = est.check_reversibility(trans_mat) ##################################################################### # Analysis of markov chain and transition matrix ##################################################################### mcmm_ana = ana.MarkovModel(trans_mat)
if args.plot: try: import matplotlib.pyplot as plt except ImportError: print "No matplotlib available, import failed." ##################################################################### # import data ##################################################################### data_importer = dataImp.SimpleDataImporter(args.iFile, i_delimiter=" ") ##################################################################### # k-means clustering ##################################################################### cluster = cl.kMeans(data_importer.get_data(), args.numCluster) cluster.discretize() ##################################################################### # estimation of transition matrix ##################################################################### chain = np.asarray(cluster.get_labels(), dtype=np.int64) count_mat = est.compute_count_matrix(chain, i_tau=1) trans_mat = est.estimate_transition_matrix(count_mat, 10000, 1e-3) is_reversible, check_mat = est.check_reversibility(trans_mat) ##################################################################### # Analysis of markov chain and transition matrix ##################################################################### mcmm_ana = ana.MarkovModel(trans_mat)