msmbuilder.msm._ratematrix.dK_dtheta_A

msmbuilder.msm._ratematrix.dK_dtheta_A(exptheta, n, u, inds, A, out=None)

Compute the sum of the Hadamard (element-wise) product of the derivative of (the rate matrix, K, with respect to the free parameters,`theta`, dK_ij / dtheta_u) and another matrix, A.

Since dK/dtheta_u is a sparse matrix with a known sparsity structure, it’s more efficient to just do sum as we construct it, and never save the matrix elements directly.

Parameters:

exptheta : array

The element-wise exponential of the free parameters, theta. These values are the linearized elements of the upper triangular portion of the symmetric rate matrix, S, followed by the equilibrium weights.

n : int

Dimension of the rate matrix, K, (number of states)

u : int

The index, 0 <= u < len(exptheta) of the element in theta to construct the derivative of the rate matrix, K with respect to.

inds : array, optional (default=None)

Sparse linearized triu indices exptheta. If not supplied, exptheta is assumed to be a dense parameterization of the upper triangular portion of the symmetric rate matrix followed by the log equilibrium weights, and must be of length n*(n-1)/2 + n. If inds is supplied, it is a set of indices, with len(inds) == len(exptheta), 0 <= inds < n*(n-1)/2+n, giving the indices of the nonzero elements of the upper triangular elements of the rate matrix to which exptheta correspond.

A : array of shape=(n, n), optional

If not None, an arbitrary (n, n) matrix to be multiplied element-wise with the derivative of the rate matrix, dKu.

out : [output], optional array of shape=(n, n)

If not None, out will contain the matrix dKu on exit.

Returns:

s : double

The sum of the element-wise product of dK/du and A, if A is not None.

Versions