deeptime.markov.tools.estimation.girsanov_reweighted_count_matrix¶
- deeptime.markov.tools.estimation.girsanov_reweighted_count_matrix(dtraj, lag, reweighting_factors, sliding=True, sparse_return=True, nstates=None)¶
Generate a Girsanov reweighted count matrix from given microstate trajectory. [1]
- Parameters:
dtraj (array_like or list of array_like) – Discretized trajectory or list of discretized trajectories.
lag (int) – Lagtime in trajectory steps.
reweighting (tuple) – Enforce a count-matrix with reweighting factors
shape=(g,M).gis the likelihood ratio between probability measures withdim=(len(dtraj)-lag), ifeta.shape==dtraj.shape.Mis the likelihood ratio between the path probabilitiy densities withdim=(len(dtraj)-lag), ifeta.shape==dtraj.shape.sliding (bool) – By default
True, the sliding window approach is used for transition counting.sparse_return (bool, optional) – Whether to return a dense or a sparse matrix.
nstates (int, optional) – Enforce a count-matrix with
shape=(nstates, nstates).
- Returns:
C – The Girsanov path reweighted count matrix at given lag in coordinate list format.
- Return type:
scipy.sparse.coo_matrix
Notes
Transition counts can be obtained from microstate trajectory using the sliding approach. By sliding along the trajectory and counting all transitions sperated by the lagtime \(\tau\).
Transition counts \(c_{ij}(\tau)\) are reweighted according to
\[c_{ij}(\tau)=\lim_{m\rightarrow\infty}\sum_{\nu_k\in S_{\tau,m}} g([\mathbf{x}_0]_k)\mathbf{1}_{B_i}([\mathbf{x}_0]_k) \cdot M_{\mathbf{x},\tau}(\nu_k)\mathbf{1}_{B_j}([\mathbf{x}_n]_k). \]Where \(\mathbf{1}_{B_i}\) is the indicator function for state \(B_i\).
References
Example
>>> import numpy as np >>> from deeptime.markov.tools.estimation import girsanov_reweighted_count_matrix
>>> dtraj = np.array([0, 0, 1, 0, 1, 1, 0, 0]) >>> tau = 2
In this example, the bias and target potential would be the same. Subtract the one to get the same length of the discrete trajectory
len(eta+1)and random number arrayeta.>>> g = [np.ones(len(dtraj)-1)] >>> M = [np.zeros(len(dtraj)-1)] >>> reweighting_factors = (g,M)
Use the reweighting approach as
>>> C_sliding = girsanov_reweighted_count_matrix(dtraj[:-1], tau, reweighting_factors)
The generated matrix is a sparse matrix in CSR-format. For convenient printing we convert it to a dense ndarray.
>>> C_sliding.toarray() array([[1., 2.], [1., 1.]])