Engineering Math

 

 

 

Conditional Probability

 

For this topic, I just put the link to the topic Conditional Probabliy in MathIsFun. This is the best explanation that I could find and I don't think I can do better than this.

A conditional probability answers one question: how likely is an event, once we know that another event has happened? The known event shrinks the set of possible outcomes, and the probability is measured again inside that smaller set. This page shows the definition with pictures and a probability tree, then turns it around into Bayes rule, with small numerical examples along the way.

What does a conditional probability mean ?

The vertical bar in P(Y | R) reads as "given". So P(Y | R) is the probability of Y, given that R has happened. Let's build it from a picture before we write the formula.

The illustration below starts with a disc of balls on the left. The disc is split into a red region R and a blue region B, and each region holds yellow and pink balls. The first step picks a region, with probability P(R) or P(B). The second step picks a ball inside the chosen region. So P(Y | R) is the chance of a yellow ball when we only look inside the red region. The grey arrows at the top show that the probability of red and yellow together, P(R ∩ Y), is the product of the two steps.

 

Picking a red or blue region, then a yellow ball, with P(R), P(B), P(Y|R) and P(Y|B)

 

P(R and Y) = P(R) P(Y|R)

 

P(Y|R) = P(R and Y) / P(R)

  • The product rule comes first : P(R ∩ Y) = P(R) P(Y | R) follows the two steps of the picture, first the region and then the ball.
  • The definition is the product rule divided by P(R) : P(Y | R) = P(R ∩ Y) / P(R). It only makes sense when P(R) > 0.
  • P(Y | R) and P(R | Y) are different numbers : the first looks for yellow among the red balls, and the second looks for red among the yellow balls.

A fair die gives a quick check. Let R be "the roll is even", so R = {2, 4, 6}, and let Y be "the roll is greater than 3". Then R ∩ Y = {4, 6}, so P(Y | R) = (2/6) / (3/6) = 2/3. Without the condition, P(Y) is only 1/2. Knowing that the roll is even makes Y more likely.

Sometimes the condition changes nothing. Let Y be "the roll is 1 or 2" instead. Then P(Y) = 1/3, and R ∩ Y = {2}, so P(Y | R) = (1/6) / (3/6) = 1/3. The two numbers are equal, and this is the definition of independent events. Two events are independent when P(Y | R) = P(Y), which is the same as P(R ∩ Y) = P(R) P(Y).

How does a probability tree show the same rule ?

The picture with balls works for one pair of events. A probability tree does the same job in a form that grows to any number of steps, and it also shows the complement of each event, written with a superscript c.

The tree below starts with event A. The first branches carry P(A) and P(Ac). The second branches carry the conditional probabilities of B and Bc, given the first branch. Each end point is a joint probability, and it equals the product of the branches along its path.

Probability tree starting with A and then B

The tree below splits the same outcomes in the other order. It starts with B and then branches on A.

Probability tree starting with B and then A

  • Multiply along a path : the end point of the path A then B is P(A ∩ B) = P(A) P(B | A).
  • Add across the paths that share an outcome : B happens on two paths of the first tree, so P(B) = P(A) P(B | A) + P(Ac) P(B | Ac). This is the law of total probability.
  • The branches from one node add up to 1 : P(B | A) + P(Bc | A) = 1, because one of the two must happen.
  • The two trees reach the same joint probabilities : P(A ∩ B) at the top of the first tree equals P(B ∩ A) at the top of the second tree. The Bayes Rule section uses exactly this.

Why we care about this ?

One of the very important technique (topics) in engineering is the application of Bayes rule (Bayesian probability) and the conditional probablity  is a core of Bayes rule.

In a receiver, conditional probabilities appear everywhere. The channel is described by P(received | sent), the probability of what arrives given what was transmitted. The bit error rate is such a conditional probability. The receiver, however, needs the opposite direction. It sees the received value and must decide what was sent, so it needs P(sent | received).

Let's take a binary channel that flips each bit with probability 0.1. Suppose the transmitter sends 0 with probability 0.8 and 1 with probability 0.2. If the receiver sees 1, the probability that 0 was actually sent is 0.8 x 0.1 / (0.8 x 0.1 + 0.2 x 0.9) = 0.08 / 0.26, which is about 0.31. So a received 1 is still correct about 69 percent of the time, not 90 percent, because the prior favours 0. Bayes rule in the next section is the tool that makes this turn from P(received | sent) to P(sent | received).

  • A channel model gives P(received | sent) : error rates and noise distributions are conditional probabilities in this direction.
  • A detector needs P(sent | received) : MAP detection picks the symbol with the largest value of this probability.
  • The prior changes the answer : the same channel gives different decisions when one symbol is sent more often than the other.

Bayes Rule

Bayes rule reverses a conditional probability. It takes P(B | A), which is often easy to measure, and returns P(A | B), which is often the number we actually need.

Regarding the intuitive explanation of the Bayes Rule, I would recommed this video(From 00:15:00). Watch the video first and then check if this equation and illustration make sense to you.

 

Bayes rule P(A|B) = P(A) P(B|A) / P(B)

The illustration below derives the rule from the two probability trees of the previous section. The highlighted end points, P(A ∩ B) in the upper tree and P(B ∩ A) in the lower tree, are the same event. So their two products are equal, P(A) P(B | A) = P(B) P(A | B). Dividing both sides by P(B) gives Bayes rule.

Derivation of Bayes rule from two probability trees

In practice, P(B) is rarely given directly. We compute it with the law of total probability from the upper tree, P(B) = P(A) P(B | A) + P(Ac) P(B | Ac). Each term in the rule then has a name. P(A) is the prior, P(B | A) is the likelihood, P(B) is the evidence, and P(A | B) is the posterior.

Here is a detector example with numbers. A target is present in 1 percent of the observations. The detector raises an alarm for 90 percent of the targets. It also raises a false alarm for 5 percent of the observations with no target. Given an alarm, what is the probability that a target is present? The evidence is P(alarm) = 0.01 x 0.9 + 0.99 x 0.05 = 0.0585. So P(target | alarm) = 0.009 / 0.0585, which is about 0.15. Most alarms are false, because targets are rare and the no-target case contributes most of the alarms.

  • Bayes rule comes from writing one joint probability in two ways : P(A) P(B | A) = P(B) P(A | B).
  • The evidence P(B) usually comes from the law of total probability : sum over every way that B can happen.
  • A rare event keeps a low posterior even with a good test : in the example, a 90 percent detection rate still gives only about 15 percent confidence in an alarm.