Real problems are full of uncertainty. A symptom does not prove a disease, and a sensor can be wrong. Probability gives a principled way to reason when we are unsure.
Sources of Uncertainty
Uncertainty comes from incomplete information, from noisy sensors, from chance in the world, and from vague concepts. A rule such as IF fever THEN flu is only sometimes right. Pure logic, which gives only true or false, cannot express this.
Probability Basics
The probability of an event is a number from 0 to 1 that measures how likely it is. The probabilities of all outcomes sum to 1. For two events, the conditional probability P(A | B) is the probability of A given that B has happened, equal to P(A and B) divided by P(B). Two events are independent if P(A and B) = P(A) × P(B).
Bayes' Theorem
Bayes' theorem updates a belief when evidence arrives: P(H | E) = P(E | H) × P(H) / P(E). Here H is a hypothesis, such as a disease, and E is the evidence, such as a test result. P(H) is the prior, P(E | H) is the likelihood, and P(H | E) is the posterior. Medical diagnosis, spam filtering and many learning methods use it. A Bayesian network is a graph in which nodes are variables and edges show direct influence, with a table of probabilities at each node. It lets us reason about many uncertain variables with far fewer numbers than a full table.
Definition: Bayes' theorem. A rule that gives the probability of a hypothesis after seeing evidence, P(H|E) = P(E|H) × P(H) / P(E), by combining the prior belief with the likelihood of the evidence.
Other Methods
Certainty factors, used in the early expert system MYCIN, attach a number between -1 and 1 to each rule and fact. Dempster-Shafer theory allows belief to be given to sets of outcomes and expresses ignorance. Fuzzy logic, which is studied in Unit IV, deals with vague concepts.
Table 2.4: Probability terms
| Term | Meaning | Notation |
|---|---|---|
| Prior | Belief before evidence | P(H) |
| Likelihood | Chance of evidence if H is true | P(E given H) |
| Posterior | Belief after evidence | P(H given E) |
| Joint | Both events together | P(A and B) |
Example 2.4: Using Bayes' theorem
Problem: A disease affects 1 percent of people. A test is positive for 90 percent of people who have it, and for 5 percent of people who do not. A person tests positive. What is the probability of the disease?
Solution:
- P(H) = 0.01, P(E | H) = 0.90, P(E | not H) = 0.05.
- P(E) = 0.90 × 0.01 + 0.05 × 0.99 = 0.009 + 0.0495 = 0.0585.
- P(H | E) = 0.009 / 0.0585 = 0.1538.
Result: The probability is about 15 percent, much lower than the 90 percent that people often guess, because the disease is rare.
ph, pe_h, pe_nh = 0.01, 0.90, 0.05
pe = pe_h * ph + pe_nh * (1 - ph)
print(round(pe_h * ph / pe, 4))
Output
0.1538
Common mistakes
- Mixing up P(H | E) and P(E | H).
- Ignoring the prior, so that a rare disease seems far too likely after a positive test.
- Multiplying probabilities of events that are not independent.
Key takeaways
- Probability measures likelihood from 0 to 1.
- Bayes' theorem: P(H|E) = P(E|H) × P(H) / P(E).
- The prior is the belief before the evidence, the posterior after.
- A Bayesian network shows how variables influence each other.
Practice questions
- State Bayes' theorem.
- What is a prior probability?
- Why is probability useful in AI?
Answers to the practice questions
- P(H|E) = P(E|H) × P(H) / P(E).
- The probability of a hypothesis before seeing the evidence.
- It lets a system reason and decide when information is incomplete or uncertain.
Sources
- Official BCA syllabus Artificial Intelligence and Expert Systems, course code 25BCA405DS02, Unit II
