r"""Compute implied time scales of given transition matrix

    Parameters
    ----------
    T : (M, M) ndarray
        Transition matrix
    tau : int, optional
        lag time
    k : int, optional
        Number of time scales
    reversible : bool, optional
        Indicate that transition matirx is reversible
    mu : (M,) ndarray, optional
        Stationary distribution of T

    Returns
    -------
    ts : (N,) ndarray
        Implied time scales of the transition matrix.
        If k=None then N=M else N=k

    Notes
    -----
    If reversible=True the the eigenvalues of the similar symmetric
    matrix `\sqrt(\mu_i / \mu_j) p_{ij}` will be computed.

    The precomputed stationary distribution will only be used if
    reversible=True.

def timescales(T, tau=1, k=None, reversible=False, mu=None):
    r"""Compute implied time scales of given transition matrix

    Parameters
    ----------
    T : (M, M) ndarray
        Transition matrix
    tau : int, optional
        lag time
    k : int, optional
        Number of time scales
    reversible : bool, optional
        Indicate that transition matirx is reversible
    mu : (M,) ndarray, optional
        Stationary distribution of T

    Returns
    -------
    ts : (N,) ndarray
        Implied time scales of the transition matrix.
        If k=None then N=M else N=k

    Notes
    -----
    If reversible=True the the eigenvalues of the similar symmetric
    matrix `\sqrt(\mu_i / \mu_j) p_{ij}` will be computed.

    The precomputed stationary distribution will only be used if
    reversible=True.

    """
    values = eigenvalues(T, reversible=reversible, mu=mu)

    """Sort by absolute value"""
    ind = np.argsort(np.abs(values))[::-1]
    values = values[ind]

    if k is None:
        values = values
    else:
        values = values[0:k]

    """Compute implied time scales"""
    return timescales_from_eigenvalues(values, tau)