|Conditional probability can be illustrated with dice problems. What is the
probability that you rolled a 12 on a pair of normal 6-sided dice, given that
at least one of the dice shows a 6? This is the same question as the following:
roll a pair of dice until at least one of the dice shows 6 -- what is the
probability that your final roll has 6 on BOTH dice. The surprising answer is
1/11 since of the 36 equally likely rolls, 11 have at least one 6 and 1 of these
11 has 6 on both dice.
Our goal is to solve a generalized version of this problem in which we
roll nDice identical dice, each with sides labelled 1,2,...,maxSide. We want
to know the probability that the sum of the dice is greater than or equal to theSum given that at least
one of the dice shows the value v. Create a
class Conditional that contains a method probability that is given nDice,maxSide,
v, and theSum and that returns the desired conditional probability.