algorithm to compute the probabilities of output variable