Engineering Mathematics · Probability & Statistics
Conditional Probability and Bayes Rule
In Engineering Mathematics because engineering decisions update when new evidence arrives, and conditional probability is the formal language for that update.
The same event can look more or less likely once you learn new information. This topic uses count tables to make conditioning and Bayes updates visible before formula manipulation takes over.
- Engineering Mathematics
- Medium level
- 4 concepts
1Conditioning changes the denominator
Conditional probability is the original probability table viewed inside a restricted world. The numerator is the part of the event you want, but the denominator is only the world named after the vertical bar.
That denominator change is the whole lesson. P(A|B) and P(B|A) usually answer different questions because they restrict to different worlds.
Figure. Conditioning throws away rows outside the given event. The denominator changes from all rows to only the rows inside B.
Read a conditional probability
- Given worldUse the event after the bar as the denominator.
- Target partCount the overlap between target and given.
- DivideOverlap count divided by given-world count.
| Actual positive | Actual negative | Total | |
|---|---|---|---|
| Predicted positive | 30 | 10 | 40 |
| Predicted negative | 20 | 40 | 60 |
| Total | 50 | 50 | 100 |
Two conditionals from one table
From the validation table, compute P(actual\ positive | predicted\ positive) and P(predicted\ positive | actual\ positive).
- Inside predicted-positive world30/(30+10)=30/40=0.75
- Inside actual-positive world30/(30+20)=30/50=0.60
- Compare0.75\ne0.60 because the denominators are different
Pro tip. The two statements use the same overlap count 30, but they answer different conditional questions.
In a table, 18 users clicked and 12 did not among 30 users shown a banner. What is P(\mathrm{clicked}\mid\mathrm{shown})?
- 18/30=0.60
- 18/100=0.18
- 12/30=0.40
- 30/18=1.67
Conditioning on shown means the denominator is the 30 shown users, not the full population.
2Bayes updates belief by filtering evidence counts
Bayes rule is often safest when read through counts. After evidence arrives, keep only the evidence column or row and ask what fraction of that restricted group belongs to the hypothesis.
A diagnostic-style table makes the posterior concrete: true positives compete with false positives inside the positive-test world.
Figure. Bayes from counts compares the evidence rows that came from the hypothesis with the evidence rows that did not. The posterior is the true-positive part of the evidence pool.
Update from a diagnostic table
- Start populationLay out condition-present and condition-absent counts.
- Apply evidenceKeep the positive-test counts from both groups.
- PosteriorDivide true positives by all positives.
| Condition present | Condition absent | Total | |
|---|---|---|---|
| Test positive | 45 | 95 | 140 |
| Test negative | 5 | 855 | 860 |
| Total | 50 | 950 | 1000 |
Posterior probability after a positive test
In 1000 people, 50 have a condition. The test catches 45 of those and falsely flags 95 people without the condition. Compute the posterior probability after a positive test.
- Positive-test world45+95=140 people
- Condition-present inside that world45 people
- Posterior45/140=0.3214
- Roundedabout 32.1\%
Pro tip. Even with 45 of 50 cases caught, the posterior is only about 32 percent because false positives are numerous in the positive-test world.
Coding lab. Compute a posterior from diagnostic counts runs in the app, with checks on your output.
A positive alert group has 24 true faults and 56 false alerts. What is P(\mathrm{fault}\mid\mathrm{alert})?
- 24/80=0.30
- 24/56=0.43
- 56/80=0.70
- 80/24=3.33
Inside the alert world there are 24+56=80 cases, and 24 are true faults.
3Base rates decide how much evidence can move belief
A strong-looking signal can disappoint when the target condition is rare. The base rate controls how many true cases are available before the test starts, while the false-positive rate controls how many non-cases leak into the evidence group.
This is not a medical-only issue. Fraud detection, anomaly alerts, rare defect monitors, and classifier warnings all face the same base-rate arithmetic.
Figure. A rare condition starts with a small base-rate pool. Even a good test can draw many false positives from the much larger absent pool.
Audit a rare-event alert
- Base casesCompute how many target cases exist before the alert.
- True alertsApply sensitivity to the target cases.
- False alertsApply false-positive rate to the many non-target cases.
Rare defect alert
Among 10,000 parts, 1 percent are defective. A monitor catches 90 percent of defective parts and falsely flags 5 percent of good parts. Compute the chance a flagged part is truly defective.
- Defective parts0.01\cdot10000=100
- True flags0.90\cdot100=90
- Good parts and false flags9900 good, 0.05\cdot9900=495 false flags
- Posterior90/(90+495)=90/585=0.1538
Pro tip. The alert is useful, but most flagged parts are still good because good parts are so much more common.
A rare event occurs in 2 percent of 5000 items. How many event items exist before any test?
- 100
- 250
- 50
- 4900
0.02\cdot5000=100. The base count limits how many true positives can exist.
4Bayes can be read as odds times evidence strength
Bayes updates can also be read in odds form. Prior odds say how plausible the hypothesis was before evidence; the likelihood ratio says how much more common the evidence is under the hypothesis than under its alternative.
This view is useful in engineering diagnostics because each new signal can be treated as an evidence multiplier, as long as the modeling assumptions behind combining signals are honest.
Figure. Odds form multiplies prior rarity by evidence strength. Prevalence 5 percent gives prior odds 1/19. Likelihood ratio 0.90/0.10 = 9. Posterior odds 9/19 convert to probability 9/28.
Use odds form
- Prior oddsConvert prior probability to odds p:(1-p).
- Evidence strengthCompute likelihood ratio P(E|H)/P(E|not H).
- Posterior oddsMultiply prior odds by the likelihood ratio, then convert back if needed.
Odds update from the same diagnostic test
Use prevalence 5 percent, sensitivity 90 percent, and false-positive rate 10 percent. Compute the posterior after a positive test using odds.
- Prior odds0.05/0.95=1/19
- Likelihood ratio0.90/0.10=9
- Posterior odds(1/19)\cdot9=9/19
- Posterior probability(9/19)/(1+9/19)=9/28=0.3214
Pro tip. Odds form reaches the same 32.1 percent posterior while separating prior rarity from evidence strength.
Coding lab. Update odds with a likelihood ratio runs in the app, with checks on your output.
Prior odds are 1:9 and the likelihood ratio is 4. What are posterior odds before converting to probability?
- 4:9
- 1:36
- 5:9
- 4:13
Odds form multiplies the prior odds by the evidence strength: (1/9)\cdot4=4/9, or 4:9.
Notes
- Conditional probability restricts attention to the world where the given evidence has already occurred.
- Bayes rule reverses the conditioning direction by combining a prior belief with evidence under each hypothesis.
- Base rates matter because the evidence denominator includes both true and false signal sources.
Formulas
- P(A | B) = P(A and B) / P(B), provided P(B) > 0.
- P(A | B) = P(B | A)P(A) / P(B).
- Posterior odds = prior odds x likelihood ratio.
Exam traps & shortcuts
- Read conditioning as 'inside the B-world now' before using any algebra.
- In diagnostic tables, count first; a high test accuracy can still leave many false positives when the condition is rare.
Recap
Conditioning is denominator control; Bayes is evidence-based denominator control in reverse.
- Conditioning
- The event after the bar defines the world you divide by.
- Bayes counts
- After evidence arrives, true evidence and false evidence share the same denominator.
- Base rate
- Rare targets can leave low posteriors even after strong-looking alerts.
- Odds
- Posterior odds equal prior odds times the evidence likelihood ratio.
Practise Conditional Probability and Bayes Rule
Reading is free and needs no account. Practice, mocks and progress live in the app.
- A 5-question practice set that ends the chapter
- 4 quick checks with worked explanations
- Timed mocks scored with the real marking scheme
- Readiness tracked per topic, kept on your device