When knowledge is uncertain, probability theory gives a rational way to combine evidence and decide.

Uncertainty and Probability

Logic deals in true and false, but a doctor cannot say with certainty that toothache means a cavity. Uncertainty arises from laziness (too many exceptions to list), theoretical ignorance and practical ignorance (tests not done). Probability P(a) is a number from 0 to 1 measuring the degree of belief in a sentence a given the evidence. The rules: 0 ≤ P(a) ≤ 1; P(true) = 1; P(a ∨ b) = P(a) + P(b) − P(a ∧ b); and P(¬a) = 1 − P(a). Conditional probability P(a | b) = P(a ∧ b) / P(b) is the probability of a given that b is known. Independence: P(a ∧ b) = P(a)P(b). A rational agent chooses the action with the highest expected utility.

Bayes' Rule

From P(a ∧ b) = P(a | b)P(b) = P(b | a)P(a) we get Bayes' rule: P(a | b) = P(b | a) · P(a) / P(b). It lets us compute the probability of a cause given an effect (diagnostic direction) from the probability of the effect given the cause (causal direction), which is easier to know. P(a) is the prior, P(b | a) the likelihood, and P(a | b) the posterior; the denominator is found from P(b) = P(b | a)P(a) + P(b | ¬a)P(¬a). Bayes' rule underlies spam filters, medical diagnosis and machine learning (naive Bayes).

Definition: Bayes' rule. P(a | b) = P(b | a)·P(a) / P(b): the probability of a hypothesis given evidence equals the likelihood of the evidence times the prior, divided by the probability of the evidence.

Bayesian Networks

A Bayesian (belief) network is a directed acyclic graph in which each node is a random variable, links show direct influence, and each node has a conditional probability table given its parents. The joint distribution factors as P(x₁, ..., xₙ) = ∏ P(xᵢ | parents(xᵢ)), which needs far fewer numbers than a full joint table. Classic example: Burglary and Earthquake cause Alarm; Alarm causes JohnCalls and MaryCalls. Inference by enumeration or variable elimination answers queries such as "P(Burglary | JohnCalls, MaryCalls)". Related models: Markov models, hidden Markov models and naive Bayes classifiers.

Table 3.9: Terms of Bayes' rule

Term Meaning Medical test example
Prior P(D) Belief before evidence 1 percent have the disease
Likelihood P(+∣D) Chance of evidence given hypothesis 90 percent sensitivity
Evidence P(+) Total chance of the evidence Positives overall
Posterior P(D∣+) Belief after evidence Chance of disease given a positive

Example 3.9: Medical test with Bayes' rule

Problem: 1 percent of people have a disease. A test is positive for 90 percent of those with the disease and for 5 percent of those without. A person tests positive. Find the probability of the disease.

Solution:

  1. P(D) = 0.01; P(+ | D) = 0.90; P(+ | ¬D) = 0.05.
  2. P(+) = 0.90 × 0.01 + 0.05 × 0.99 = 0.009 + 0.0495 = 0.0585.
  3. P(D | +) = 0.009 / 0.0585 = 0.154.

Result: Only about 15.4 percent: because the disease is rare, most positives are false positives.

p_d, sens, fpr = 0.01, 0.90, 0.05
p_pos = sens * p_d + fpr * (1 - p_d)
post = sens * p_d / p_pos
print(f"P(+) = {p_pos:.4f}")
print(f"P(D | +) = {post:.3f}")
p_d2 = 0.10
post2 = sens * p_d2 / (sens * p_d2 + fpr * (1 - p_d2))
print(f"with prior 10%: {post2:.3f}")

Output

P(+) = 0.0585
P(D | +) = 0.154
with prior 10%: 0.667

Common mistakes

  • Confusing P(a | b) with P(b | a) (the prosecutor's fallacy).
  • Ignoring the prior probability (base-rate neglect).
  • Assuming independence when variables are dependent.
  • Adding probabilities of events that are not mutually exclusive without subtracting the overlap.

Key takeaways

  • Probability measures degree of belief between 0 and 1.
  • Conditional: P(a | b) = P(a ∧ b)/P(b); Bayes: P(a | b) = P(b | a)P(a)/P(b).
  • A Bayesian network factors the joint distribution using parents' conditional tables.
  • Rational choice maximises expected utility.

Practice questions

  1. State Bayes' rule.
  2. Why is the posterior only 15 percent in the medical example?
  3. What is a Bayesian network?

Answers to the practice questions

  1. P(a | b) = P(b | a)·P(a) / P(b).
  2. The disease is rare, so most positive results come from the large healthy group.
  3. A directed acyclic graph of random variables with conditional probability tables, representing a joint distribution compactly.

Sources

  • Official BCA syllabus Artificial Intelligence, course code 26BCA404DS04, Unit III