msmtools.analysis.mfpt(T, target, origin=None, tau=1, mu=None)

Mean first passage times (from a set of starting states - optional) to a set of target states.

  • T (ndarray or scipy.sparse matrix, shape=(n,n)) – Transition matrix.
  • target (int or list of int) – Target states for mfpt calculation.
  • origin (int or list of int (optional)) – Set of starting states.
  • tau (int (optional)) – The time-lag (in elementary time steps of the microstate trajectory) at which the given transition matrix was constructed.
  • mu ((n,) ndarray (optional)) – The stationary distribution of the transition matrix T.

m_t – Mean first passage time or vector of mean first passage times.

Return type:

ndarray, shape=(n,) or shape(1,)


The mean first passage time \(\mathbf{E}_x[T_Y]\) is the expected hitting time of one state \(y\) in \(Y\) when starting in state \(x\).

For a fixed target state \(y\) it is given by

\[\begin{split}\mathbb{E}_x[T_y] = \left \{ \begin{array}{cc} 0 & x=y \\ 1+\sum_{z} T_{x,z} \mathbb{E}_z[T_y] & x \neq y \end{array} \right.\end{split}\]

For a set of target states \(Y\) it is given by

\[\begin{split}\mathbb{E}_x[T_Y] = \left \{ \begin{array}{cc} 0 & x \in Y \\ 1+\sum_{z} T_{x,z} \mathbb{E}_z[T_Y] & x \notin Y \end{array} \right.\end{split}\]

The mean first passage time between sets, \(\mathbf{E}_X[T_Y]\), is given by

\[\mathbb{E}_X[T_Y] = \sum_{x \in X} \frac{\mu_x \mathbb{E}_x[T_Y]}{\sum_{z \in X} \mu_z}\]


[1]Hoel, P G and S C Port and C J Stone. 1972. Introduction to Stochastic Processes.


>>> import numpy as np
>>> from msmtools.analysis import mfpt
>>> T = np.array([[0.9, 0.1, 0.0], [0.5, 0.0, 0.5], [0.0, 0.1, 0.9]])
>>> m_t = mfpt(T, 0)
>>> m_t
array([  0.,  12.,  22.])