A signal flags 80 percent of the faulty items it inspects. When it flags an item, is that item 80 percent likely to be faulty? The two questions sound alike, but they measure the same overlap against different groups of items, and in the constructed example on this page the second answer is only about 31 percent. This lesson defines events and conditional probability, derives Bayes’ rule, shows how the base rate shapes a posterior probability, and separates independence from conditional independence.
Key terms
Events and joint probability
Definition A probability model starts from a sample space , the set of all possible outcomes. An event is a set of outcomes, a subset to which the model assigns a probability, and it occurs when the outcome lies in . In a finite model every subset can be an event. A probability gives each event a number with and , and it adds over disjoint events, so whenever , and likewise for any finite or countable list of pairwise disjoint events. The complement contains the outcomes not in , and . The joint probability of events and is , the probability that both occur. When is finite and all its outcomes are equally likely,
the number of outcomes in divided by the number of all outcomes.
In plain words An event matches a yes or no question about the outcome, answered once the outcome is known. A joint probability asks for two answers to be yes at the same time. Every probability refers to a stated population or process, such as one item drawn at random from a stated set, and changing that reference can change the number.
Example A constructed set of items has been inspected. Each item is faulty or sound, and a signal either flagged it or did not. Draw one item at random, with all equally likely.
| Flagged | Not flagged | Total | |
|---|---|---|---|
| Faulty | 8 | 2 | 10 |
| Sound | 18 | 72 | 90 |
| Total | 26 | 74 | 100 |
Let be the event that the drawn item is faulty and the event that it was flagged. Then , its complement has , the flag event has , and the joint probability is . These are exact probabilities for a draw from this table. Counts from a real inspection study would only estimate the probabilities of a larger population, with sampling and measurement error.
Conditional probability
Definition Let and be events with . The conditional probability of given is
When this ratio is undefined. For a fixed event with , the rule that sends each event to is itself a probability, so for example . The two conditional probabilities and share the numerator but divide it by different probabilities. When and are both positive, they are equal exactly when or .
In plain words Conditioning on means keeping only the outcomes in and asking what share of that group, measured by probability, also lies in . The event after the bar names the reference group and supplies the denominator. Swapping the two events swaps the reference group, and so it changes the question being asked.
Example In the inspection table, of the faulty items are flagged, so . Reversing the condition, of the flagged items are faulty, so
about . Among the unflagged items, are faulty, so , about . A flag raises the probability of a fault from and the absence of a flag lowers it, but neither one settles the state of a particular item.
Bayes’ rule
Definition Let and be events with and . The joint probability can be written in two ways, and . Setting them equal and dividing by gives Bayes’ rule,
When also , the law of total probability splits by whether occurs,
In this form is the prior probability of the state , the conditional probabilities and are the likelihoods of the observed evidence under each state, and is the posterior probability. A likelihood is a probability of the evidence given a state, and it is not a probability of the state.
In plain words Bayes’ rule turns the probability of the evidence given the state, which is what a detector’s rates describe, into the probability of the state given the evidence, which is what a decision about one flagged item needs. The denominator counts every way the evidence can arise. Leaving out the flags that come from sound items would treat every flag as a true fault.
Example For the inspection table, , and . The two routes to a flag have probabilities and , so and
the same answer that the table gives directly.
Base rate and posterior probability
Definition The base rate of a state is its probability in the population where a prediction is made, before the evidence at hand is taken into account. In Bayes’ rule it is the prior . The posterior probability is the probability of the state after conditioning on the observed evidence . If the two likelihoods and are positive and held fixed, the posterior
is a strictly increasing function of the base rate for .
In plain words The base rate is what is known before the signal, and the posterior is what is known after it. A detector with fixed rates means less when the condition it detects is rare, because the false flags from the large group of sound items can outnumber the true flags from the small group of faulty ones. A probabilistic classifier aims to report posterior probabilities of the classes given the features, so the right outputs depend on the class base rates of the population where it is used. A posterior does not by itself choose an action, since that also depends on the costs of the possible mistakes.
Example Keep and , but move to a population where only percent of items are faulty. The routes to a flag now have probabilities and , so
The posterior fell from about to about , although the detector’s rates did not change. The comparison assumes that those rates carry over to the new population. If conditions there also change how the signal behaves, new likelihoods are needed as well as a new base rate.
Independence
Definition Events and are independent if
When this is equivalent to . If and are independent, then so are and . An event with probability or is independent of every event. Disjoint events that both have positive probability are never independent, because their joint probability is while the product of their probabilities is positive.
In plain words For events with positive probability, independence means that learning one of them occurred leaves the probability of the other unchanged. It is a property of the probability model. It should be justified by how the outcomes are produced or checked against the model’s numbers, and it never follows from what the events are called. Disjoint events with positive probabilities are strongly dependent, since each one rules out the other.
Example In the inspection table, , while . The two differ, so and are not independent, as the comparison also shows. That dependence is exactly what makes the signal useful. A signal independent of the state would leave the probability of a fault at whether or not it flagged the item.
Conditional independence
Definition Let be an event with . Events and are conditionally independent given if
Conditional independence given a variable, such as the true state of an item, means that this equation holds given each value of the variable that has positive probability, here given and given . In general neither independence nor conditional independence implies the other.
In plain words Conditional independence is an independence statement made inside each group defined by the condition. Two sensors that both respond to faults can be independent among the faulty items and among the sound items, yet flag together more often than independence would predict across the whole population, because both follow the same hidden state. An independence claim should always name what it conditions on, and dropping the condition changes the claim.
Example Two sensors each flag a faulty item with probability and a sound item with probability , and as before. Let and be the events that the first and the second sensor flag, and assume they are conditionally independent given the state. Given a faulty item both flag with probability , and given a sound item with probability , so
Each sensor flags with probability , and is not , so and are not independent. Two flags give the posterior , well above the from one flag. The conditional independence is an assumption about how the sensors work. It does not follow from their equal rates.
Check yourself
- A constructed set of messages contains spam messages. A filter flags of the spam messages and of the other messages. One message is chosen at random, with all equally likely. Find the probability that a spam message is flagged, the probability that a flagged message is spam, and the probability that an unflagged message is spam.
Show the answer
Let be the event that the message is spam and the event that it is flagged. Within the spam messages, . The filter flags messages, so within that group
about . The unflagged messages contain spam messages, so , about . The first two answers share the numerator , the count of flagged spam, but divide it by different groups, which is why reversing the condition changes the answer.
- In a constructed model, percent of items are faulty. A signal flags percent of faulty items and percent of sound items. Find the probability that a flagged item is faulty, and explain why the answer is not . Then find the same posterior in a population where percent of items are faulty, assuming the signal’s rates carry over.
Show the answer
Let be the event that an item is faulty and the event that it is flagged. The routes to a flag have probabilities and , so and
about . In expected counts per items, the model gives faulty items with flags and sound items with flags, and of the flags belong to faulty items. The number is , the share of faulty items that get flagged, which answers a different question with a different reference group.
With a base rate of the routes have probabilities and , so
The same flag is now much weaker evidence, because sound items supply most of the flags.
- Two sensors each flag a faulty item with probability and a sound item with probability , independently of each other given the state, and percent of items are faulty. Let and be the events that the first and the second sensor flag. A colleague says the probability that both flag is . Find , the correct and the posterior probability of a fault when both flag.
Show the answer
Let be the event that the item is faulty. By the law of total probability, , and the same holds for . Conditional independence lets the probabilities multiply only within each state, so
The colleague’s product is less than half of this. The sensors are not independent across the whole population, because both follow the same hidden state, and indeed , far above . When both flag,
compared with after a single flag.