def statdist(generator):
generator = np.asarray(generator)<EOL>n = generator.shape[<NUM_LIT:0>]<EOL>with warnings.catch_warnings():<EOL><INDENT>warnings.filterwarnings("<STR_LIT:ignore>")<EOL>lu, piv = spl.lu_factor(generator.T, check_finite=False)<EOL><DEDENT>left = lu[:-<NUM_LIT:1>,:-<NUM_LIT:1>]<EOL>right = -lu[:-<NUM_LIT:1>,-<NUM_LIT:1>]<EOL>try:<EOL><INDENT>res = spl.solve_triangular(left, right, check_finite=False)<EOL><DEDENT>except:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>res = np.append(res, <NUM_LIT:1.0>)<EOL>return (n / res.sum()) * res<EOL>
Compute the stationary distribution of a Markov chain.

    Parameters
    ----------
    generator : array_like
        Infinitesimal generator matrix of the Markov chain.

    Returns
    -------
    dist : numpy.ndarray
        The unnormalized stationary distribution of the Markov chain.

    Raises
    ------
    ValueError
        If the Markov chain does not have a unique stationary distribution.