def powerMethod(self, tol = 1e-8, maxiter = 1e5):
        """
        Carry out the power method and store the result in the class attribute ``pi``. 
        Repeatedly takes the dot product between ``P`` and ``pi`` until the norm is smaller than the prespecified tolerance ``tol``.
          
        Parameters
        ----------
        tol : float, optional(default=1e-8)
            Tolerance level for the precision of the end result. A lower tolerance leads to more accurate estimate of ``pi``.
        maxiter : int, optional(default=1e5)
            The maximum number of power iterations to be carried out.            
        
        Example
        -------
        >>> P = np.array([[0.5,0.5],[0.6,0.4]])
        >>> mc = markovChain(P)
        >>> mc.powerMethod()
        >>> print(mc.pi) 
        [ 0.54545455  0.45454545]
        
        Remarks
        -------
        The power method is robust even when state space becomes large (more than 500.000 states), whereas the other methods may have some issues with memory or convergence.
        The power method may converge slowly for Markov chains where states are rather disconnected. That is, when the expected time to go from one state to another is large.        
        """
        P = self.getIrreducibleTransitionMatrix().T #take transpose now to speed up dot product.
        size = P.shape[0]        
        pi = np.zeros(size);  pi1 = np.zeros(size)
        pi[0] = 1;
        n = norm(pi - pi1,1); i = 0;
        while n > tol and i < maxiter:
            pi1 = P.dot(pi)
            pi = P.dot(pi1)
            n = norm(pi - pi1,1); i += 1
        self.pi = pi
def powerMethod ( self , tol = 1e-8 , maxiter = 1e5 ) : P = self . getIrreducibleTransitionMatrix ( ) . T size = P . shape [ 0 ] pi = np . zeros ( size ) ; pi1 = np . zeros ( size ) pi [ 0 ] = 1 ; n = norm ( pi - pi1 , 1 ) ; i = 0 ; while n > tol and i < maxiter : pi1 = P . dot ( pi ) pi = P . dot ( pi1 ) n = norm ( pi - pi1 , 1 ) ; i += 1 self . pi = pi
Carry out the power method and store the result in the class attribute ``pi``. 
        Repeatedly takes the dot product between ``P`` and ``pi`` until the norm is smaller than the prespecified tolerance ``tol``.
          
        Parameters
        ----------
        tol : float, optional(default=1e-8)
            Tolerance level for the precision of the end result. A lower tolerance leads to more accurate estimate of ``pi``.
        maxiter : int, optional(default=1e5)
            The maximum number of power iterations to be carried out.            
        
        Example
        -------
        >>> P = np.array([[0.5,0.5],[0.6,0.4]])
        >>> mc = markovChain(P)
        >>> mc.powerMethod()
        >>> print(mc.pi) 
        [ 0.54545455  0.45454545]
        
        Remarks
        -------
        The power method is robust even when state space becomes large (more than 500.000 states), whereas the other methods may have some issues with memory or convergence.
        The power method may converge slowly for Markov chains where states are rather disconnected. That is, when the expected time to go from one state to another is large.