trans_per_state¶
-
mdtools.dtrj.
trans_per_state
(dtrj, axis=- 1)[source]¶ Count the number of transitions leading into or out of a given state.
- Parameters
dtrj (array_like) – Array containing the discrete trajectory. All elements of the array must be integers or floats whose fractional part is zero, because they are interpreted as the indices of the states in which a given compound is at a given frame. However, unlike ordinary discrete trajectory in MDTools, dtrj can have an arbitrary shape.
axis (int) – The axis along which to search for state transitions. For ordinary discrete trajectories with shape
(n, f)
or(f,)
, wheren
is the number of compounds andf
is the number of frames, set axis to-1
. If you parse a transposed discrete trajectory to dtrj, set axis to0
.
- Returns
hist_start (numpy.ndarray) – Histogram counting how many state transitions started from a given state, i.e. how many transitons led out of a given state.
hist_end (numpy.ndarray) – Histogram counting how many state transitions ended it a given state, i.e. how many transitions led into a given state.
Notes
The histograms contain the counts for all states ranging from the minimum to the maximum state in dtrj in whole numbers. This means, the states corresponding to the counts in hist_start and hist_end are given by
numpy.arange(np.min(dtrj), np.max(dtrj)+1)
.Examples
>>> dtrj = np.array([[1, 2, 2, 3, 3, 3], ... [2, 2, 3, 3, 3, 1], ... [3, 3, 3, 1, 2, 2], ... [1, 3, 3, 3, 2, 2]]) >>> hist_start, hist_end = mdt.dtrj.trans_per_state(dtrj) >>> # Number of transitions starting from the 1st, 2nd or 3rd state >>> hist_start array([3, 2, 3]) >>> # Number of transitions ending in the 1st, 2nd or 3rd state >>> hist_end array([2, 3, 3])
Iterprete first dimension as frames and second dimension as compounds:
>>> hist_start, hist_end = mdt.dtrj.trans_per_state(dtrj, axis=0) >>> hist_start array([3, 3, 4]) >>> hist_end array([3, 3, 4])