Calculating the probability of events