A114 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

A11 · Lesson 4 · Conditional probability

Updating chances when you learn something

A network loses 1% of its packets. A packet has just been lost: what's the chance the next one is lost too? If losses were unrelated, still 1%. On a real link, where interference comes in bursts, it might be 40%. Knowing that one thing happened changes the chances of another, and conditional probability is the arithmetic of that change. It's also the tool for any process that happens in stages: which factory line made a chip, then whether that chip is bad.

  • Two dice are thrown 20,000 times. Each bar is one of the 36 outcomes, numbered row by row: bars 1 to 6 have the first die showing 1, bars 7 to 12 have it showing 2, and so on.
  • Event B: the first die shows b. Event A: the sum is at least s. The readouts measure P(B), P(A∩B) and their ratio.
  • Set b=6 and s=10. Knowing the first die is a 6, how likely is a sum of 10 or more? Compare with the chance before you knew.

Predict

A chip comes from line 1 (60% of production, 2% defective) or line 2 (40%, 5% defective). What fraction of all chips is defective?

Name it

Conditional probability

The probability of A given B is

P(A∣B)=P(A∩B)P(B)(P(B)>0)

Learning that B happened shrinks the sample space to B; the outcomes of A that are still possible are those in A∩B, and dividing by P(B) rescales so the new sample space has probability 1. With equally likely outcomes it's just counting inside B: of the 6 outcomes with the first die showing 6, three have a sum of 10 or more, so P=36, against 636 before.

A conditional probability is a probability: it obeys all the axioms, so for example P(Ac∣B)=1−P(A∣B).

The multiplication rule

Turned around, the definition gives the chance that two things both happen, one stage at a time:

P(A∩B)=P(B)P(A∣B)

Drawing two parts from 10, of which 3 are bad: P(both bad)=310×29=115. The second factor is conditional, because the first draw changed what's left.

Total probability

If B1,B2,… split the sample space into pieces that don't overlap (which line made the chip, which symbol was sent), then

P(A)=∑iP(A∣Bi)P(Bi)

Draw it as a tree: the first branches are the Bi with their chances, the second branches are A or not, given each Bi. Multiply along a path to get that path's chance, and add the paths that end in A.

Order matters

P(A∣B) and P(B∣A) are different numbers. The chance a defective chip came from line 2 is not the chance a line-2 chip is defective. Lesson 5 turns one into the other.

Worked example

A link loses 1% of packets, and 0.4% of consecutive pairs are both lost. Given that a packet was lost, what is the chance the next one is lost?

Show the solution
  1. Apply the definition. Write L1 for this packet lost and L2 for the next one lost: P(L2∣L1)=P(both lost)P(L1)=0.0040.01=0.4
  2. Losses come in bursts. One loss makes the next 40 times more likely than average.
  3. Why it matters. A retransmission scheme that assumes independent losses would badly underestimate how often two copies in a row fail.

Answer given a loss, the next packet is lost with chance 0.4.

Worked example

A box has 10 fuses, 3 of them blown. You take two without looking. What is the chance that exactly one is blown?

Show the solution
  1. Blown, then good. This is one of the two paths in the tree that give exactly one blown fuse: 310×79=2190
  2. Good, then blown. This is the other: 710×39=2190
  3. Add the two paths. P=2190+2190=4290=0.467
  4. Check by counting. (31)(71)(102)=2145

Answer the chance that exactly one is blown is 0.467.

Worked example

60% of parts come from supplier A, with 1% defective, and 40% from B, with 3% defective. What fraction of parts are defective?

Show the solution
  1. Split by supplier. By the law of total probability: P(bad)=0.6×0.01+0.4×0.03=0.006+0.012=0.018
  2. Read it. 1.8% is a weighted average of the two rates.
  3. Turning it around. Lesson 5 asks the reverse question: given a bad part, how likely is it to be from B?

Answer 1.8% of parts are defective.

Check

P(A∩B) = 0.05 and P(B) = 0.2. What is P(A∣B)?

Check

Two dice are thrown, and the first shows 5. What is the chance that the sum is 9 or more?

Check

Line 1 makes 0.6 of the chips with a defect rate of 0.01; line 2 makes the rest with a defect rate of 0.05. What fraction of all chips is defective?

Check

A box holds 10 parts, 3 of them defective. You draw two without replacement. What is the chance both are defective?

Check

A link loses a fraction 0.01 of its packets, and a fraction 0.003 of consecutive pairs are both lost. Given a loss, what is the chance the next packet is lost?

Check

A test catches 99% of bad boards. Does that mean 99% of the boards it flags are bad?

Check

A fraction 0.6 of parts come from supplier A, with defect rate 0.01; the rest from B, with defect rate 0.05.

(a)

What fraction of all parts are defective?

Check

A link loses a fraction a of packets, and a fraction b of consecutive pairs are both lost.

Step 1

Given one packet was lost, what is the chance the next one is too?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Explain why

Why does P(A∣B) divide by P(B)?

Practice

Keep practicing

9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.