def get_stationary_distribution ( self ) : # The stationary distribution is proportional to the left-eigenvector # associated with the largest eigenvalue (i.e., 1) of the transition # matrix. check_is_fitted ( self , "transmat_" ) eigvals , eigvecs = np . linalg . eig ( self . transmat_ . T ) eigvec = np . real_if_close ( eigvecs [ : , np . argmax ( eigvals ) ] ) return eigvec / eigvec . sum ( )
compute eigenvalues of transition matrix in python
Compute the stationary distribution of states .
def get_stationary_distribution(self):
        """Compute the stationary distribution of states.
        """
        # The stationary distribution is proportional to the left-eigenvector
        # associated with the largest eigenvalue (i.e., 1) of the transition
        # matrix.
        check_is_fitted(self, "transmat_")
        eigvals, eigvecs = np.linalg.eig(self.transmat_.T)
        eigvec = np.real_if_close(eigvecs[:, np.argmax(eigvals)])
        return eigvec / eigvec.sum()