back_jump_prob

mdtools.dtrj.back_jump_prob(dtrj, continuous=False, discard_neg=False, discard_neg_btw=False, return_norm=False, verbose=False)[source]

Calculate the back-jump probability averaged over all states.

Take a discrete trajectory and calculate the probability to return back to the initial state at time \(t_0 + \Delta t\), given that a state transition has occurred at time \(t_0\).

Parameters:
  • dtrj (array_like) – The discrete trajectory. Array of shape (n, f), where n is the number of compounds and f is the number of frames. The shape can also be (f,), in which case the array is expanded to shape (1, f). The elements of dtrj are interpreted as the indices of the states in which a given compound is at a given frame.

  • continuous (bool) – If False, calculate the probability that a compound returns back to its initial state at time \(t_0 + \Delta t\). This probability might be regarded as the “discontinuous” or “intermittent” back-jump probability.

    If True, calculate the probability that a compound returns back to its initial state at time \(t_0 + \Delta t\) under the condition that it has continuously been in the new state from time \(t_0\) until \(t_0 + \Delta t\), i.e. that the compound does not visit other states in between. This probability might be regarded as the “continuous” or “true” back-jump probability.

  • discard_neg (bool, optional) – If True, discard negative states, i.e. discard back jumps starting from (and consequently ending in) a negative state.

  • discard_neg_btw (bool, optional) – If True, discard back jumps when the compound has visited a negative state between \(t_0\) and \(t_0 + \Delta t\).

  • return_norm (bool, optional) – If True, return the normalization factors for all lag times.

  • verbose (bool, optional) – If True print a progress bar.

Returns:

  • bj_prob (numpy.ndarray) – Array of shape (f-1,) containing the back-jump probability for each possible lag time \(\Delta t\). The k-th element of the array is the probability that a compound returns back to its initial state k frames after a state transition has occurred. Another interpretation could be that the k-th element of the array is the percentage of compounds that return back to there initial state k frames after a state transition has occurred.

  • norm (numpy.ndarray) – Array of the same shape as bj_prob containing the corresponding normalization factors. The k-th element of bj_prob * norm is the number of compounds that return back to there initial state k frames after a state transition has occurred.

See also

mdtools.dtrj.back_jump_prob_discrete()

Calculate the back-jump probability resolved with respect to the states a in second discrete trajectory

mdtools.dtrj.remain_prob()

Calculate the probability that a compound is still (or again) in the same state as at time \(t_0\) after a lag time \(\Delta t\)

mdtools.dtrj.leave_prob()

Calculate the probability that a compound leaves its state after a lag time \(\Delta t\) given that it has entered the state at time \(t_0\)

Examples

>>> dtrj = np.array([1, 3, 3, 3, 1, 2, 2])
>>> mdt.dtrj.back_jump_prob(dtrj)
array([0., 0., 0., 1., 0., 0.])
>>> mdt.dtrj.back_jump_prob(dtrj, continuous=True)
array([0., 0., 0., 1., 0., 0.])
>>> dtrj = np.array([1, 3, 3, 3, 2, 2, 1])
>>> mdt.dtrj.back_jump_prob(dtrj)
array([0., 0., 0., 0., 0., 1.])
>>> mdt.dtrj.back_jump_prob(dtrj, continuous=True)
array([0., 0., 0., 0., 0., 0.])
>>> dtrj = np.array([[1, 3, 3, 3, 1, 2, 2],
...                  [1, 3, 3, 3, 2, 2, 1]])
>>> mdt.dtrj.back_jump_prob(dtrj)
array([0. , 0. , 0. , 0.5, 0. , 0.5])
>>> mdt.dtrj.back_jump_prob(dtrj, continuous=True)
array([0. , 0. , 0. , 0.5, 0. , 0. ])
>>> dtrj = np.array([[1, 2, 2, 1, 3, 3, 3],
...                  [1, 2, 2, 3, 3, 3, 1]])
>>> mdt.dtrj.back_jump_prob(dtrj)
array([0. , 0. , 0.2, 0. , 0. , 0.5])
>>> mdt.dtrj.back_jump_prob(dtrj, continuous=True)
array([0. , 0. , 0.2, 0. , 0. , 0. ])
>>> dtrj = np.array([[1, 2, 2, 1, 3, 3, 3],
...                  [1, 5, 5, 5, 5, 5, 1]])
>>> mdt.dtrj.back_jump_prob(dtrj)
array([0.  , 0.  , 0.25, 0.  , 0.  , 0.5 ])
>>> mdt.dtrj.back_jump_prob(dtrj, continuous=True)
array([0.  , 0.  , 0.25, 0.  , 0.  , 0.5 ])
>>> dtrj = np.array([[1, 2, 2, 1, 2, 2],
...                  [2, 2, 1, 2, 2, 1]])
>>> mdt.dtrj.back_jump_prob(dtrj)
array([0. , 0.4, 0.5, 0. , 0. ])
>>> mdt.dtrj.back_jump_prob(dtrj, continuous=True)
array([0. , 0.4, 0.5, 0. , 0. ])

Discard negative states:

>>> dtrj = np.array([[ 1,  2,  2,  1,  3,  3,  3],
...                  [-1,  2,  2, -1,  3,  3,  3],
...                  [ 1, -2, -2,  1,  3,  3,  3],
...                  [ 1,  2,  2,  3,  3,  3,  1],
...                  [-1,  2,  2,  3,  3,  3, -1],
...                  [ 1,  2,  2, -3, -3, -3,  1]])
>>> mdt.dtrj.back_jump_prob(dtrj)
array([0. , 0. , 0.2, 0. , 0. , 0.5])
>>> mdt.dtrj.back_jump_prob(dtrj, discard_neg=True)
array([0.        , 0.        , 0.18181818, 0.        , 0.        ,
       0.5       ])
>>> mdt.dtrj.back_jump_prob(dtrj, discard_neg_btw=True)
array([0. , 0. , 0.2, 0. , 0. , 0.5])
>>> mdt.dtrj.back_jump_prob(
...     dtrj, discard_neg=True, discard_neg_btw=True
... )
array([0.        , 0.        , 0.16666667, 0.        , 0.        ,
       0.5       ])
>>> mdt.dtrj.back_jump_prob(dtrj, continuous=True)
array([0. , 0. , 0.2, 0. , 0. , 0. ])
>>> mdt.dtrj.back_jump_prob(dtrj, continuous=True, discard_neg=True)
array([0.        , 0.        , 0.18181818, 0.        , 0.        ,
       0.        ])
>>> mdt.dtrj.back_jump_prob(
...     dtrj, continuous=True, discard_neg_btw=True
... )
array([0.        , 0.        , 0.16666667, 0.        , 0.        ,
       0.        ])
>>> mdt.dtrj.back_jump_prob(
...     dtrj,
...     continuous=True,
...     discard_neg=True,
...     discard_neg_btw=True,
... )
array([0.   , 0.   , 0.125, 0.   , 0.   , 0.   ])