def get_prediction(q, DFAs):
	"""
	For a set of DFAs (one for each goal), returns the predicted goal and corresponding probability, under
	the Bayesian inference method
	"""

	probs = {}

	sum_probs = 0
	probs_sorted = []

	for _g in DFAs:
		if DFAs[_g].guess(q[_g]) == 1:
			probs[_g] = DFAs[_g].goal_priors[_g] * DFAs[_g].recall / (1-DFAs[_g].tnr)
		else:
			probs[_g] = DFAs[_g].goal_priors[_g] * (1 - DFAs[_g].recall) / DFAs[_g].tnr

		sum_probs += probs[_g]

		probs_sorted.append((probs[_g], _g))


	probs_sorted.sort()
	probs_sorted.reverse()

	return probs_sorted[0][1], probs_sorted[0][0] / sum_probs