Calculating probabilities with given conditions