#NEWLINE# def forwardbackward( stateprior , transition , emission , observations , numstates , elem_size = numpy . longdouble ) : #NEWLINE# #INDENT# '\n\tCalculates the probability of a sequence given the HMM.\n\t' #NEWLINE# alpha = calcalpha ( stateprior , transition , emission , observations , numstates , elem_size ) #NEWLINE# return sum ( alpha [ ( - 1 ) ] )