Almost every interesting probability question is conditional. We do not ask how likely a failure is in absolute terms, but how likely it is given that the disk temperature is high; not how likely it is that a login is fraudulent, but how likely it is given that it comes from an unusual country at three in the morning. Conditional probability is the tool that formalises this «given that».
The definition
The probability of A given B is written P(A|B) and defined as:
P(A|B) = P(A and B) / P(B), with P(B) > 0
The idea is simple: knowing that B has happened shrinks the space of possible outcomes to B. Within this new universe, we ask what fraction is also occupied by A.
An example with a die
We roll a fair die. What is the probability that a 6 came up, given that an even number came up? The even outcomes are {2, 4, 6}, three equally likely cases, and 6 is one of them: P(6 | even) = 1/3. With the formula: P(6 and even) = 1/6, P(even) = 1/2, so (1/6)/(1/2) = 1/3.
Contingency tables
With real data, the clearest way to reason is a table of counts. Suppose we analyse 1,000 logins to a service, classified by origin and by the result of a later check:
| Fraudulent | Legitimate | Total | |
|---|---|---|---|
| Usual country | 10 | 890 | 900 |
| Unusual country | 30 | 70 | 100 |
| Total | 40 | 960 | 1,000 |
From this we can read different probabilities that are often confused:
- P(fraudulent) = 40/1,000 = 4%.
- P(fraudulent | unusual country) = 30/100 = 30%.
- P(unusual country | fraudulent) = 30/40 = 75%.
The last two answer completely different questions. The first says: if I see a login from an unusual country, how worried should I be? The second says: among frauds, how many come from unusual countries? A rule blocking all unusual countries would stop 75% of frauds, but 7 out of 10 blocked logins would belong to legitimate users.
The inversion error
Swapping P(A|B) with P(B|A) is one of the most frequent and dangerous mistakes. In the courtroom it has a name, the prosecutor's fallacy: «the probability that an innocent person has this profile is one in a million, so the probability that the defendant is innocent is one in a million». That is not so: the second probability also depends on how many people in the relevant population might have that profile. Moving correctly from one direction to the other requires Bayes' theorem and knowledge of the base rates.
The product rule
Rewriting the definition gives:
P(A and B) = P(B) · P(A|B) = P(A) · P(B|A)
It is used to compute probabilities of events in sequence. Drawing two cards without replacement from a 52-card deck, the probability that both are aces is (4/52) · (3/51) = 12/2,652 ≈ 0.0045. The second factor is conditional: if the first card was an ace, 3 out of 51 remain.
Independence
Two events are independent if knowing that one has happened does not change the probability of the other: P(A|B) = P(A). Equivalently:
P(A and B) = P(A) · P(B)
Two tosses of a coin are independent; two cards drawn without replacement are not.
Independence does not mean mutual exclusivity
This is a common confusion. Two mutually exclusive events with positive probability are in fact strongly dependent: if one happens, the other becomes impossible. «A 1 comes up» and «a 2 comes up» on the same roll are mutually exclusive, and knowing that a 1 came up brings the probability of a 2 to zero.
Independence is an assumption to be checked
Reliability calculations often multiply: if each disk in a system has a 0.01 probability of failing in a year, the probability that two fail together seems to be 0.0001. But disks bought from the same batch, in the same server, with the same vibrations and temperatures, are not independent. Failures tend to cluster, and the real probability of a double failure can be much higher than the product suggests. It is one of the reasons why backups on different media and in different places are worth more than simple local redundancy.
Conditional independence
Two events can be dependent in general but independent once a third factor is known. Ice-cream sales and sunburns are correlated, but once the amount of sunshine on a given day is fixed they stop being so. This idea underlies the most widely used probabilistic models, from naive Bayes classifiers to Bayesian networks, and anticipates the topic of confounding variables.
How to practise
- Always build the restricted space: «given B» means «I look only inside B».
- When you have data, draw the table of counts before writing formulas.
- Read the condition aloud: «among those who… how many…?». It helps avoid inversion.
- Before multiplying probabilities, ask whether a common mechanism links the events.
In short
- P(A|B) is the fraction of B in which A also happens: conditioning shrinks the space.
- P(A|B) and P(B|A) can be very different: inverting them is a serious error.
- The product rule lets you compute events in sequence.
- Independence means one event does not change the probability of the other, not that they exclude each other.
- Independence must be justified: common causes often break it.