Monday, May 23, 2011

Section 1.8 - Conditional Probability

Let the trial T≥2 be flipping 10 coins such that at least one comes up heads. What is the probability that an outcome of T≥2 has at least two heads?

The requirement that at least one coin land heads-up is a condition,? and the resulting probability is known as known as a conditional probability. There’s at least three ways to find conditional probabilities: direct counting, indirect counting, and compliment probability.?

Before getting to the solutions, it’s important to recall a fact, and understand why it’s important. What is T≥2’s sample space? The sample space is the set of all possible trial outcomes. T≥2’s sample space is not { ti | 0 ≤ i < 1024 }? because t0 is not a possible outcome for T≥2.? Instead, T≥2’s sample space is { ti | 0 < i < 1024 }, because now every ti has at least one heads. The sample space is symmetric, and of size 1023, which means ti for 0 < i < 1024 has probability 1/1023. These are the two most common errors when dealing with conditional probabilities:? forgetting to adjust the sample space to accommodate the conditions, and misadjusting the sample space so it contains too many or too few outcomes.

The simplest and most straightforward solution (in some sense) is to directly count all the outcomes satisfying the predicate P(ti) = ti has at least two heads and add their probabilities together. There are 1013 such outcomes,? and the resulting probabilities sum to 1013/1023 = 0.99.

Direct counting doesn’t scale well with sample-space size or outcome predicate complexity. However, because the predicate partitions the sample space into two subsets, it may be possible to indirectly count the satisfactory outcomes by counting the unsatisfactory outcomes and using the fact that
unsatisfactory size + satisfactory size = sample-space size
to get
satisfactory size = sample-space size - unsatisfactory size
In this case, unsatisfactory size is 10,? and so satisfactory size = 1023 - 10 = 1013, and the probability is 1013/1023 = 0.99.

The third solution is a variant of the indirect counting because it too relies on outcome predicate partitioning:
Pr(unsatisfactory outcome) + Pr(satisfactory outcome) = Pr(sample-space outcome)
Pr(sample-space outcome) is certainty—that is, 1—and so
Pr(satisfactory outcome) = 1 - Pr(unsatisfactory outcome)
Pr(unsatisfactory outcome) is known as the compliment probability. In this case, Pr(unsatisfactory outcome) = 10/1023 = 0.01, to get Pr(satisfactory outcome) = 1 - 0.01 = 0.99.

Indirect counting and compliment probability are useful to the extent that counting the unsatisfactory outcomes is easier than counting the satisfactory outcomes. If counting the two kinds of outcomes are of similar difficultly, it’s likely that none of the three solution techniques is going to have a clear advantage over the others.


Example 1.8-2. Roll two fair die; T is the trial in which the outcome contains at least one even number. What is the probability that the outcome sums to 8?

T’s sample space is not { (x, y) | x, y ∈ [1..6] } because, for example, the sample space contains (3, 3), which is not an outcome for T.? T's sample space is
{ (x, y) | x, y ∈ [1..6] ∧ (even(x) ∨ even(y)) }
The haskell expression
length [ (x, y) | x <- [1..6], y <- [1..6], even x || even y ]
tells us the sample-space size is 27. The sample space is symmetric, and each outcome has probability 1/27.

Direct counting solution: How many outcomes sum to 8? Because every outcome contains an even number, and even + odd is odd (and 8 is even), even-odd rolls can be ignored. Of the even-even pairs, how many sum to 8?

D1222444666
D2246246246
sum468681081012
There are three satisfactory outcomes, and the probability of T producing one of the is 3/27 = 1/9.

Indirect-counting solution: How many outcomes do not sum to eight? All the pairs containing an odd number don't, and there are 9 + 9 = 18 of those.? There may be a tendency to forget that not all the even-even pairs sum to eight,? and forget to count the ones that don't. From the previous solution, six even-even pairs don't sum to eight, for a total of 18 + 6 = 24 unsatisfactory outcomes. There are 27 - 24 = 3 satisfactory outcomes, for a probability of 3/27 = 1/9.

Compliment-probability solution: From the indirect-counting solution, there are 24 unsatisfactory outcomes, and the probability of producing one is 24/27 = 8/9. The probability of producing a satisfactory outcome is 1 - 8/9 = 1/9.

In this example it was more complicated to count the unsatisfactory outcomes than it was to count the satisfactory outcomes.