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)
.g
is the likelihood ratio between probability measures withdim=(len(dtraj)-lag)
, ifeta.shape==dtraj.shape
.M
is 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 .
Transition counts are reweighted according to
Where is the indicator function for state .
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.]])