示例#1
0
    def test_is_rate_matrix(self):
        K_copy = self.K.copy()
        self.assertTrue(is_rate_matrix(self.K, self.tol),
                        "K should be evaluated as rate matrix.")

        self.assertTrue(
            np.allclose(self.K.data, K_copy.data)
            and np.allclose(self.K.offsets, K_copy.offsets),
            "object modified!")
示例#2
0
文件: ctmc.py 项目: rahmanhpu/bkit
def jump_matrix(rate_matrix):
    """Extract the jump probabilities from a rate matrix.

    Parameters
    ----------
    rate_matrix : (M, M) array_like
        A transition rate matrix, with row sums equal to zero.

    Returns
    -------
    (M, M) ndarray
        The jump matrix (embedded transition matrix) derived from 
        `rate_matrix`.

    """
    rate_matrix = np.asarray(rate_matrix)
    if not msmana.is_rate_matrix(rate_matrix):
        raise ValueError('matrix must be row infinitesimal stochastic')
    jump_rates = -rate_matrix.diagonal()
    jump_matrix = rate_matrix / jump_rates[:, np.newaxis]
    np.fill_diagonal(jump_matrix, 0)
    return jump_matrix
示例#3
0
文件: ctmc.py 项目: rahmanhpu/bkit
 def rate_matrix(self, value):
     value = np.asarray(value)
     if not msmana.is_rate_matrix(value):
         raise ValueError('matrix must be row infinitesimal stochastic')
     self._rate_matrix = value
示例#4
0
    def test_IsRateMatrix(self):
        self.assertTrue(is_rate_matrix(self.A), 'A should be a rate matrix')

        # manipulate matrix so it isn't a rate matrix any more
        self.A[0][0] = 3
        self.assertFalse(is_rate_matrix(self.A), 'matrix is not a rate matrix')