stationary_distribution.py
def stationary_distribution(trans_prob):
    """
        Find the stationary distribution for an MRP

        Inputs:
                trans_prob: transition probability matrix.

        Output:
                pi: stationary distribution.
    """

    # find the eigenvalues and left eigenvectors of P
    eigvalues, eigvectors = LA.eig(trans_prob.T)

    # find the stationary distribution
    for idx, eigval in enumerate(eigvalues):
        if abs(1.0 - eigval.real) < 1e-8:
            pi = eigvectors[:, idx].real
            pi = pi / sum(pi)
            assert np.allclose(np.dot(pi, trans_prob), pi), "Cannot find the stationary distribution."
            return pi

    raise Exception('Cannot find the stationary distribution')

        Find the stationary distribution for an MRP

        Inputs:
                trans_prob: transition probability matrix.

        Output:
                pi: stationary distribution.
    
Find the stationary distribution for an MRP
Inputs:
trans_prob: transition probability matrix.

stationary distribution.
Find the stationary distribution for an MRP Inputs : trans_prob : transition probability matrix . stationary distribution .
def stationary_distribution(trans_prob):
    eigvalues, eigvectors = LA.eig(trans_prob.T)
    for idx, eigval in enumerate(eigvalues):
        if abs(1.0 - eigval.real) < 1e-8:
            pi = eigvectors[:, idx].real
            pi = pi / sum(pi)
            assert np.allclose(np.dot(pi, trans_prob), pi), "Cannot find the stationary distribution."
            return pi
    raise Exception('Cannot find the stationary distribution')
def stationary_distribution ( trans_prob ) : eigvalues , eigvectors = LA . eig ( trans_prob . T ) for idx , eigval in enumerate ( eigvalues ) : if abs ( 1.0 - eigval . real ) < 1e-8 : pi = eigvectors [ : , idx ] . real pi = pi / sum ( pi ) assert np . allclose ( np . dot ( pi , trans_prob ) , pi ) , "Cannot find the stationary distribution." return pi raise Exception ( 'Cannot find the stationary distribution' )
Find the stationary distribution for an MRP
Inputs:
trans_prob: transition probability matrix.
Find the stationary distribution for an MRP Inputs : trans_prob : transition probability matrix .
"""
        Find the stationary distribution for an MRP

        Inputs:
                trans_prob: transition probability matrix.

        Output:
                pi: stationary distribution.
    """ # find the eigenvalues and left eigenvectors of P # find the stationary distribution
trans_prob