def test_expected_counts(self): p0 = self.mu T = self.T N = 20 EC_n = expected_counts(T, p0, N) """ If p0 is the stationary vector the computation can be carried out by a simple multiplication """ EC_true = N * self.mu[:, np.newaxis] * T assert_allclose(EC_true, EC_n) N = 2000 EC_n = expected_counts(T, p0, N) """ If p0 is the stationary vector the computation can be carried out by a simple multiplication """ EC_true = N * self.mu[:, np.newaxis] * T assert_allclose(EC_true, EC_n) """Zero length chain""" N = 0 EC_n = expected_counts(T, p0, N) EC_true = np.zeros(T.shape) assert_allclose(EC_true, EC_n)
def test_expected_counts(self): N = 50 T = self.T_sparse p0 = self.mu_sparse EC_n = expected_counts(T, p0, N) D_mu = diags(self.mu_sparse, 0) EC_true = N * D_mu.dot(T) self.assertTrue(sparse_allclose(EC_true, EC_n))