def linearMethod(self): 
        """
        Determines ``pi`` by solving a system of linear equations using :func:`spsolve`. 
        The method has no parameters since it is an exact method. The result is stored in the class attribute ``pi``.   
     
        Example
        -------
        >>> P = np.array([[0.5,0.5],[0.6,0.4]])
        >>> mc = markovChain(P)
        >>> mc.linearMethod()
        >>> print(mc.pi) 
        [ 0.54545455  0.45454545]
        
        Remarks
        -------
        For large state spaces, the linear algebra solver may not work well due to memory overflow.
        Code due to http://stackoverflow.com/questions/21308848/
        """    
        P       = self.getIrreducibleTransitionMatrix()        
      
        #if P consists of one element, then set self.pi = 1.0
        if P.shape == (1, 1):
            self.pi = np.array([1.0]) 
            return  
     
        size    = P.shape[0]
        dP      = P - eye(size)
        #Replace the first equation by the normalizing condition.
        A       = vstack([np.ones(size), dP.T[1:,:]]).tocsr()  
        rhs     = np.zeros((size,))
        rhs[0]  = 1   
        
        self.pi = spsolve(A, rhs)
Determines ``pi`` by solving a system of linear equations using :func:`spsolve`. 
        The method has no parameters since it is an exact method. The result is stored in the class attribute ``pi``.   
     
        Example
        -------
        >>> P = np.array([[0.5,0.5],[0.6,0.4]])
        >>> mc = markovChain(P)
        >>> mc.linearMethod()
        >>> print(mc.pi) 
        [ 0.54545455  0.45454545]
        
        Remarks
        -------
        For large state spaces, the linear algebra solver may not work well due to memory overflow.
        Code due to http://stackoverflow.com/questions/21308848/