prob140.MarkovChain.from_matrix¶
-
classmethod
MarkovChain.
from_matrix
(states, transition_matrix)[source]¶ Constructs a MarkovChain from a transition matrix.
Parameters: - states : iterable
List of states.
- transition_matrix : ndarray
Square transition matrix.
Returns: - MarkovChain
Examples
>>> states = [1, 2] >>> transition_matrix = np.array([[0.1, 0.9], ... [0.8, 0.2]]) >>> MarkovChain.from_matrix(states, transition_matrix) 1 2 1 0.1 0.9 2 0.8 0.2