Scenario
A patient shows symptoms. We want to determine the probability of having the flu.
Bayesian Network
graph TD
F[Flu]
Fe[Fever]
C[Cough]
F --> Fe
F --> C
style F fill:#dc3545,stroke:#0a2540,stroke-width:3px,color:#fff
style Fe fill:#32D583,stroke:#0a2540,stroke-width:3px,color:#fff
style C fill:#32D583,stroke:#0a2540,stroke-width:3px,color:#fff
Probability Tables
| P(Fever|Flu) |
| Flu | P(F=Y) |
| Yes | 0.8 |
| No | 0.2 |
| P(Cough|Flu) |
| Flu | P(C=Y) |
| Yes | 0.7 |
| No | 0.3 |
Given: Patient has Fever = Yes and Cough = Yes
Query: P(Flu = Yes | Fever = Yes, Cough = Yes) = ?
Step 1: Compute Numerator
Using: Chain Rule
P(Flu=Yes, Fever=Yes, Cough=Yes) = P(Flu=Yes) Γ P(Fever=Yes|Flu=Yes) Γ P(Cough=Yes|Flu=Yes)
Theorem:
Using the Chain Rule (Product Rule) to factorize the joint probability based on the network structure.
= 0.1 Γ 0.8 Γ 0.7
= 0.056
Step 2: Compute Denominator
Using: Marginalization
P(Fever=Yes, Cough=Yes) = Ξ£Flu P(Flu, Fever=Yes, Cough=Yes)
Theorem:
Using Marginalization (Sum Rule) β summing over all possible values of the query variable (Flu).
When Flu = Yes:
0.1 Γ 0.8 Γ 0.7 = 0.056
When Flu = No:
0.9 Γ 0.2 Γ 0.3 = 0.054
Total: 0.056 + 0.054 = 0.110
Step 3: Normalize
Using: Bayes' Rule
Theorem:
Applying Bayes' Rule β dividing by total probability to get the conditional probability.
P(Flu=Yes | Fever=Yes, Cough=Yes) =
Interpretation
If a patient has both fever and cough, there's approximately a 51% probability they have the flu.
Note: Although flu is relatively rare (10% prior probability), observing both symptoms increases
the probability to about 50%, since these symptoms are much more likely when someone has the flu (80% and 70%)
compared to when they don't (20% and 30%).
Complete Calculation Breakdown
| Flu |
P(Flu) |
P(Fever=Yes|Flu) |
P(Cough=Yes|Flu) |
Joint Probability |
| Yes |
0.1 |
0.8 |
0.7 |
0.056 |
| Numerator P(Flu=Yes, Evidence): |
0.056 |
| No |
0.9 |
0.2 |
0.3 |
0.054 |
| Sum for Flu=No: |
0.054 |
| Total Denominator P(Fever=Yes, Cough=Yes): |
0.110 |
| Final Answer: P(Flu=Yes | Fever=Yes, Cough=Yes): |
0.509 |