remain_prob_discrete

mdtools.dtrj.remain_prob_discrete(dtrj1, dtrj2, restart=1, continuous=False, discard_neg_start=False, discard_all_neg=False, verbose=False)[source]

Calculate the probability that a compound is in the same state as at time \(t_0\) after a lag time \(\Delta t\) resolved with respect to the states in second discrete trajectory.

Take a discrete trajectory and calculate the probability to find a compound in the same state as at time \(t_0\) after a lag time \(\Delta t\) given that the compound was in a specific state of another discrete trajectory at time \(t_0\).

Parameters:
  • dtrj1, dtrj2 (array_like) – The discrete trajectories. Arrays 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). Both arrays must have the same shape. The elements of the arrays are interpreted as the indices of the states in which a given compound is at a given frame.

  • restart (int, optional) – Restart every restart frames. Determines how many restarting points \(t_0\) are used for averaging.

  • continuous (bool, optional) – If True, compounds must continuously be in the same state without interruption in order to be counted (see notes of mdtools.dtrj.remain_prob()).

  • discard_neg_start (bool, optional) – If True, discard all transitions starting from a negative state (see notes of mdtools.dtrj.remain_prob()). Must not be used together with discard_all_neg.

  • discard_all_neg (bool, optional) – If True, discard all negative states (see notes of mdtools.dtrj.remain_prob()). Must not be used together with discard_neg_start.

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

Returns:

prop (numpy.ndarray) – Array of shape (f, m), where m is the number of states in the second discrete trajectory. The ij-th element of prob is the probability that a compound is in the same state of the first discrete trajectory as at time \(t_0\) after a lag time of i frames given that the compound was in state j of the second discrete trajectory at time \(t_0\).

See also

mdtools.dtrj.remain_prob()

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

Notes

See mdtools.dtrj.remain_prob() for more details about the calculation of the probability to stay in the same state and about the meaning of the continuous, discard_neg_start and discard_all_neg arguments.

If you parse the same discrete trajectory to dtrj1 and dtrj2 you will get the probability to stay in the same state for each individual state of the input trajectory. If you want the average probability over all states, use mdtools.dtrj.remain_prob().

Examples

>>> dtrj = np.array([[2, 2, 3, 3, 3]])
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj)
array([[1. , 1. ],
       [0.5, 1. ],
       [0. , 1. ],
       [0. , nan],
       [0. , nan]])
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj, continuous=True)
array([[1. , 1. ],
       [0.5, 1. ],
       [0. , 1. ],
       [0. , nan],
       [0. , nan]])
>>> dtrj = np.array([[1, 3, 3, 3, 1]])
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj)
array([[1.        , 1.        ],
       [0.        , 0.66666667],
       [0.        , 0.5       ],
       [0.        , 0.        ],
       [1.        ,        nan]])
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj, continuous=True)
array([[1.        , 1.        ],
       [0.        , 0.66666667],
       [0.        , 0.5       ],
       [0.        , 0.        ],
       [0.        ,        nan]])

The following examples were not checked to be mathematically correct!

>>> 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],
...                  [ 1,  4,  4,  4,  4, -1]])
>>> # States of the discrete trajectory:
>>> # [-2         ,-1         , 1         , 2         , 3         ]
>>> # Because the first and second discrete trajectories are the
>>> # same in this example, the resulting array contains as columns
>>> # the probability to stay in the respective state as function of
>>> # the lag time.
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj)
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [0.66666667,        nan, 0.        , 0.72727273, 0.75      ],
       [0.        ,        nan, 0.        , 0.44444444, 0.66666667],
       [0.        ,        nan, 0.        , 0.        , 0.5       ],
       [0.        ,        nan, 0.        , 0.        , 0.        ],
       [0.        ,        nan, 0.        , 0.        ,        nan]])
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj, restart=3)
array([[1.  , 1.  , 1.  , 1.  , 1.  ],
       [1.  ,  nan, 0.  , 0.75, 1.  ],
       [0.  ,  nan, 0.  , 0.5 , 0.  ],
       [0.  ,  nan, 0.  , 0.  ,  nan],
       [0.  ,  nan, 0.  , 0.  ,  nan],
       [0.  ,  nan, 0.  , 0.  ,  nan]])
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj, continuous=True)
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [0.66666667,        nan, 0.        , 0.72727273, 0.75      ],
       [0.        ,        nan, 0.        , 0.44444444, 0.66666667],
       [0.        ,        nan, 0.        , 0.        , 0.5       ],
       [0.        ,        nan, 0.        , 0.        , 0.        ],
       [0.        ,        nan, 0.        , 0.        ,        nan]])
>>> mdt.dtrj.remain_prob_discrete(
...     dtrj, dtrj, discard_neg_start=True
... )
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [       nan,        nan, 0.        , 0.72727273, 0.75      ],
       [       nan,        nan, 0.        , 0.44444444, 0.66666667],
       [       nan,        nan, 0.        , 0.        , 0.5       ],
       [       nan,        nan, 0.        , 0.        , 0.        ],
       [       nan,        nan, 0.        , 0.        ,        nan]])
>>> mdt.dtrj.remain_prob_discrete(
...     dtrj, dtrj, discard_neg_start=True, continuous=True
... )
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [       nan,        nan, 0.        , 0.72727273, 0.75      ],
       [       nan,        nan, 0.        , 0.44444444, 0.66666667],
       [       nan,        nan, 0.        , 0.        , 0.5       ],
       [       nan,        nan, 0.        , 0.        , 0.        ],
       [       nan,        nan, 0.        , 0.        ,        nan]])
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj, discard_all_neg=True)
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [       nan,        nan, 0.        , 0.8       , 1.        ],
       [       nan,        nan, 0.        , 0.66666667, 1.        ],
       [       nan,        nan, 0.        , 0.        , 1.        ],
       [       nan,        nan, 0.        ,        nan,        nan],
       [       nan,        nan,        nan,        nan,        nan]])
>>> mdt.dtrj.remain_prob_discrete(
...     dtrj, dtrj, discard_all_neg=True, continuous=True
... )
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [       nan,        nan, 0.        , 0.8       , 1.        ],
       [       nan,        nan, 0.        , 0.66666667, 1.        ],
       [       nan,        nan, 0.        , 0.        , 1.        ],
       [       nan,        nan, 0.        ,        nan,        nan],
       [       nan,        nan,        nan,        nan,        nan]])
>>> dtrj = dtrj.T
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj)
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [0.375     ,        nan, 0.25      , 0.41666667,        nan],
       [0.        ,        nan, 0.        , 0.22222222,        nan],
       [0.        ,        nan, 0.5       , 0.16666667,        nan],
       [0.        ,        nan, 1.        , 0.        ,        nan]])
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj, restart=2)
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [0.75      ,        nan, 0.        , 0.66666667,        nan],
       [0.        ,        nan, 0.        , 0.        ,        nan],
       [0.        ,        nan, 1.        , 0.33333333,        nan],
       [0.        ,        nan, 1.        , 0.        ,        nan]])
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj, continuous=True)
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [0.375     ,        nan, 0.25      , 0.41666667,        nan],
       [0.        ,        nan, 0.        , 0.11111111,        nan],
       [0.        ,        nan, 0.        , 0.        ,        nan],
       [0.        ,        nan, 0.        , 0.        ,        nan]])
>>> mdt.dtrj.remain_prob_discrete(
...     dtrj, dtrj, discard_neg_start=True
... )
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [       nan,        nan, 0.25      , 0.41666667,        nan],
       [       nan,        nan, 0.        , 0.22222222,        nan],
       [       nan,        nan, 0.5       , 0.16666667,        nan],
       [       nan,        nan, 1.        , 0.        ,        nan]])
>>> mdt.dtrj.remain_prob_discrete(
...     dtrj, dtrj, discard_neg_start=True, continuous=True
... )
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [       nan,        nan, 0.25      , 0.41666667,        nan],
       [       nan,        nan, 0.        , 0.11111111,        nan],
       [       nan,        nan, 0.        , 0.        ,        nan],
       [       nan,        nan, 0.        , 0.        ,        nan]])
>>> mdt.dtrj.remain_prob_discrete(dtrj, dtrj, discard_all_neg=True)
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [       nan,        nan, 0.5       , 0.45454545,        nan],
       [       nan,        nan, 0.        , 0.33333333,        nan],
       [       nan,        nan,        nan, 0.33333333,        nan],
       [       nan,        nan,        nan, 0.        ,        nan]])
>>> mdt.dtrj.remain_prob_discrete(
...     dtrj, dtrj, discard_all_neg=True, continuous=True
... )
array([[1.        , 1.        , 1.        , 1.        , 1.        ],
       [       nan,        nan, 0.5       , 0.45454545,        nan],
       [       nan,        nan, 0.        , 0.16666667,        nan],
       [       nan,        nan,        nan, 0.        ,        nan],
       [       nan,        nan,        nan, 0.        ,        nan]])