(self, k=1, log=True)
Returns the likelihood of the sequence
        assuming a k-th order Markov model
Returns the likelihood of the sequence
        assuming a k-th order Markov model
Returns the likelihood of the sequence assuming a k - th order Markov model
def getLikelihood(self, k=1, log=True):
        """
        Returns the likelihood of the sequence
        assuming a k-th order Markov model
        """

        if k not in self.P:
            self.fitMarkovModel(k)

        L = 0

         # Generate initial prefix
        mem = (())
        for s in self.sequence[:k]:
            mem += (s,)

        for s in self.sequence[k:]:
            L += _np.log(self.P[k][mem][s])

            # shift memory by one element
            mem = mem[1:] + (s,)

        if log:
            return L
        else:
            return _np.exp(L)
def getLikelihood ( self , k = 1 , log = True ) : if k not in self . P : self . fitMarkovModel ( k ) L = 0 # Generate initial prefix mem = ( ( ) ) for s in self . sequence [ : k ] : mem += ( s , ) for s in self . sequence [ k : ] : L += _np . log ( self . P [ k ] [ mem ] [ s ] ) # shift memory by one element mem = mem [ 1 : ] + ( s , ) if log : return L else : return _np . exp ( L )