(self, method='MLE', k=2, lanczosVecs=15, maxiter=1000)
return Hk/Hk_n
Computes the ratio between the entropy growth rate ratio between
        the k-order and first-order model of a temporal network t. Ratios smaller
        than one indicate that the temporal network exhibits non-Markovian characteristics
Computes the ratio between the entropy growth rate ratio between
        the k-order and first-order model of a temporal network t. Ratios smaller
        than one indicate that the temporal network exhibits non-Markovian characteristics
Computes the ratio between the entropy growth rate ratio between the k - order and first - order model of a temporal network t . Ratios smaller than one indicate that the temporal network exhibits non - Markovian characteristics
def getEntropyGrowthRateRatio(self, method='MLE', k=2, lanczosVecs=15, maxiter=1000):
        """
        Computes the ratio between the entropy growth rate ratio between
        the k-order and first-order model of a temporal network t. Ratios smaller
        than one indicate that the temporal network exhibits non-Markovian characteristics
        """
    
        # NOTE to myself: most of the time here goes into computation of the
        # NOTE            EV of the transition matrix for the bigger of the
        # NOTE            two graphs below (either 2nd-order or 2nd-order null)

        assert (method == 'MLE' or method=='Miller'), 'Only methods MLE or Miller are supported'
    
        # Generate k-order network
        gk = HigherOrderNetwork(self, k=k)
        g1 = HigherOrderNetwork(self, k=1)
    
        Log.add('Calculating entropy growth rate ratio ... ', Severity.INFO)
    
        # Compute entropy growth rate of observed transition matrix
        A = g1.getAdjacencyMatrix(weighted=False, transposed = True)
        Tk = gk.getTransitionMatrix()
        Tk_pi = HigherOrderNetwork.getLeadingEigenvector(Tk, normalized=True, lanczosVecs=lanczosVecs, maxiter=maxiter)

        Tk.data *=  _np.log2(Tk.data)

        # Apply Miller correction to the entropy estimation
        if method == 'Miller':
            # Here, K is the number of different k-paths that can exist based on the
            # observed edges
            K = (A**k).sum()
            print('K = ', K)

            # N is the number of observations used to estimate the transition probabilities
            # in the second-order network. This corresponds to the total edge weight in the 
            # k-order network, or - alternatively - to the number of paths of length k
            N = 0
            for p in self.paths[k]:
                N += self.paths[k][p].sum()
            print('N = ', N)
            Hk = _np.sum( Tk * Tk_pi ) + (K-1)/(2*N)
        else:
            # simple MLE estimation
            Hk = -_np.sum( Tk * Tk_pi )

        Hk = _np.absolute(Hk)

        # Compute entropy rate of null model       
        gk_n = HigherOrderNetwork(self, k=k, nullModel = True)

        # For the entropy rate of the null model, no Miller correction is needed
        # since we assume that transitions correspond to the true probabilities
        Tk_n = gk_n.getTransitionMatrix()
        Tk_n_pi = HigherOrderNetwork.getLeadingEigenvector(Tk_n)
        Tk_n.data *=  _np.log2(Tk_n.data)
        Hk_n = -_np.sum( Tk_n * Tk_n_pi )
        Hk_n = _np.absolute(Hk_n)

        Log.add('finished.', Severity.INFO)

        # Return ratio
        return Hk/Hk_n
def getEntropyGrowthRateRatio ( self , method = 'MLE' , k = 2 , lanczosVecs = 15 , maxiter = 1000 ) : # NOTE to myself: most of the time here goes into computation of the # NOTE            EV of the transition matrix for the bigger of the # NOTE            two graphs below (either 2nd-order or 2nd-order null) assert ( method == 'MLE' or method == 'Miller' ) , 'Only methods MLE or Miller are supported' # Generate k-order network gk = HigherOrderNetwork ( self , k = k ) g1 = HigherOrderNetwork ( self , k = 1 ) Log . add ( 'Calculating entropy growth rate ratio ... ' , Severity . INFO ) # Compute entropy growth rate of observed transition matrix A = g1 . getAdjacencyMatrix ( weighted = False , transposed = True ) Tk = gk . getTransitionMatrix ( ) Tk_pi = HigherOrderNetwork . getLeadingEigenvector ( Tk , normalized = True , lanczosVecs = lanczosVecs , maxiter = maxiter ) Tk . data *= _np . log2 ( Tk . data ) # Apply Miller correction to the entropy estimation if method == 'Miller' : # Here, K is the number of different k-paths that can exist based on the # observed edges K = ( A ** k ) . sum ( ) print ( 'K = ' , K ) # N is the number of observations used to estimate the transition probabilities # in the second-order network. This corresponds to the total edge weight in the  # k-order network, or - alternatively - to the number of paths of length k N = 0 for p in self . paths [ k ] : N += self . paths [ k ] [ p ] . sum ( ) print ( 'N = ' , N ) Hk = _np . sum ( Tk * Tk_pi ) + ( K - 1 ) / ( 2 * N ) else : # simple MLE estimation Hk = - _np . sum ( Tk * Tk_pi ) Hk = _np . absolute ( Hk ) # Compute entropy rate of null model        gk_n = HigherOrderNetwork ( self , k = k , nullModel = True ) # For the entropy rate of the null model, no Miller correction is needed # since we assume that transitions correspond to the true probabilities Tk_n = gk_n . getTransitionMatrix ( ) Tk_n_pi = HigherOrderNetwork . getLeadingEigenvector ( Tk_n ) Tk_n . data *= _np . log2 ( Tk_n . data ) Hk_n = - _np . sum ( Tk_n * Tk_n_pi ) Hk_n = _np . absolute ( Hk_n ) Log . add ( 'finished.' , Severity . INFO ) # Return ratio return Hk / Hk_n