def calcbeta(transition,emission,observations,numstates,elem_size=numpy.longdouble):
	beta = numpy.zeros((len(observations),numstates),dtype=elem_size)
	for s in xrange(numstates):
		beta[len(observations)-1][s] = 1.
	for t in xrange(len(observations)-2,-1,-1):
		for i in xrange(numstates):
			for j in xrange(numstates):
				beta[t][i] += transition[i][j]*emission[j][observations[t+1]]*beta[t+1][j]
	return beta
Calculates 'beta' the backward variable.
dataset/ETHPy150Open QuantSoftware/QuantSoftwareToolkit/QSTK/qstklearn/hmm.py/calcbeta