CSE-41XX
CS-4101 AI

Lecture 11.1: Probabilistic Reasoning and Bayesian Networks

An in-depth guide to Bayesian reasoning, conditional and joint probability updates, law of total probability, and Bayesian Network inference.

In real-world settings, agents must act under uncertainty. Since classical logic cannot easily handle noisy or incomplete information, we rely on probability theory to model belief.

Bayesian reasoning provides a mathematically rigorous way to update an agent's beliefs (represented as probabilities) when new evidence or observations arrive, moving from initial intuition to disciplined reasoning:

Prior belief+New evidenceUpdated belief\text{Prior belief} + \text{New evidence} \longrightarrow \text{Updated belief}

In rule-based expert systems, this relationship is expressed as: IF E is true THEN H is true {with probability p}\text{IF } E \text{ is true THEN } H \text{ is true } \{\text{with probability } p\}


Foundations of Conditional & Joint Probability

To understand Bayes' rule, we first build from basic counting principles and probability concepts.

Classical Probability & Dice Roll Model

Consider a single throw of a standard 6-sided die where obtaining a 66 is defined as the only successful event.

  • Let s=1s = 1 be the number of successful outcomes (66).
  • Let f=5f = 5 be the number of failure outcomes ({1,2,3,4,5}\{1, 2, 3, 4, 5\}).

The probability of success pp and probability of failure qq are: P(success)=p=ss+f=11+5=160.1666P(\text{success}) = p = \frac{s}{s + f} = \frac{1}{1 + 5} = \frac{1}{6} \approx 0.1666 P(failure)=q=fs+f=51+5=560.8333P(\text{failure}) = q = \frac{f}{s + f} = \frac{5}{1 + 5} = \frac{5}{6} \approx 0.8333

Since success and failure partition the outcome space, their sum equals unity: p+q=1p + q = 1

Mutually Exclusive vs. Dependent Events

  • Mutually Exclusive Events: Two events AA and BB are mutually exclusive if they cannot occur simultaneously in a single trial (e.g., obtaining both a 11 and a 66 on a single die throw). The probability of either event occurring is: P(AB)=P(A)+P(B)P(A \cup B) = P(A) + P(B)
  • Dependent Events: When events are not independent, the occurrence of one event alters the likelihood of another occurring.

Conditional & Joint Probability Derivation

From a counting perspective, the conditional probability of event AA occurring given that event BB has already occurred is defined as: P(AB)=Number of outcomes where both A and B occurNumber of outcomes where B occursP(A | B) = \frac{\text{Number of outcomes where both } A \text{ and } B \text{ occur}}{\text{Number of outcomes where } B \text{ occurs}}

In standard set and logic notation, the joint probability P(AB)P(A \cap B) (or P(AB)P(A \land B)) represents the probability that both AA and BB occur: P(AB)=P(AB)P(B)for P(B)>0P(A \cap B) = P(A | B) P(B) \quad \text{for } P(B) > 0 P(BA)=P(BA)P(A)for P(A)>0P(B \cap A) = P(B | A) P(A) \quad \text{for } P(A) > 0

Because joint probability is commutative (P(AB)=P(BA)P(A \cap B) = P(B \cap A)), we can equate both expressions: P(AB)P(B)=P(BA)P(A)P(A | B) P(B) = P(B | A) P(A)

Rearranging yields the core definition of Conditional Probability: P(AB)=P(AB)P(B)=P(BA)P(A)P(B)P(A | B) = \frac{P(A \cap B)}{P(B)} = \frac{P(B | A) P(A)}{P(B)}


Law of Total Probability & Sample Space Partitioning

When an event AA depends on a set of nn mutually exclusive and exhaustive events B1,B2,,BnB_1, B_2, \dots, B_n, the joint probability for each partition is: P(AB1)=P(AB1)P(B1)P(A \cap B_1) = P(A | B_1) P(B_1) P(AB2)=P(AB2)P(B2)P(A \cap B_2) = P(A | B_2) P(B_2) \vdots P(ABn)=P(ABn)P(Bn)P(A \cap B_n) = P(A | B_n) P(B_n)

Summing across all partitions yields the Law of Total Probability: P(A)=i=1nP(ABi)=i=1nP(ABi)P(Bi)P(A) = \sum_{i=1}^n P(A \cap B_i) = \sum_{i=1}^n P(A | B_i) P(B_i)

Binary Sample Space Partition (BB and ¬B\neg B)

If event AA depends on only two mutually exclusive events (BB and its complement ¬B\neg B), the total probabilities of AA and BB expand as: P(A)=P(AB)P(B)+P(A¬B)P(¬B)P(A) = P(A | B) P(B) + P(A | \neg B) P(\neg B) P(B)=P(BA)P(A)+P(B¬A)P(¬A)P(B) = P(B | A) P(A) + P(B | \neg A) P(\neg A)


Bayes' Theorem (Bayes' Rule)

Named after Reverend Thomas Bayes, Bayes' Theorem describes how to update the probability of a hypothesis (HH) given observed evidence (EE):

P(HE)=P(EH)×P(H)P(E)P(H | E) = \frac{P(E | H) \times P(H)}{P(E)}

By substituting the binary Law of Total Probability for P(E)P(E), we obtain the expanded form:

P(HE)=P(EH)×P(H)P(EH)P(H)+P(E¬H)P(¬H)P(H | E) = \frac{P(E | H) \times P(H)}{P(E | H)P(H) + P(E | \neg H)P(\neg H)}

Terminology Breakdown:

  • P(HE)P(H | E) (Posterior Probability): The updated probability of hypothesis HH after observing evidence EE.
  • P(EH)P(E | H) (Likelihood): The probability of observing evidence EE given that hypothesis HH is true.
  • P(H)P(H) (Prior Probability): The initial probability of hypothesis HH before observing evidence.
  • P(¬H)P(\neg H) (Complementary Prior): The prior probability of hypothesis HH being false (P(¬H)=1P(H)P(\neg H) = 1 - P(H)).
  • P(E¬H)P(E | \neg H) (Likelihood under Complement): The probability of finding evidence EE even when hypothesis HH is false (false positive rate).
  • P(E)P(E) (Marginal Likelihood / Evidence): The total probability of observing evidence EE across all possible states of the hypothesis.

Generalizing Bayes' Rule: Multiple Hypotheses & Evidence

In diagnostic reasoning, an expert often evaluates multiple hypotheses (H1,H2,,HmH_1, H_2, \dots, H_m) given one or more pieces of evidence (E1,E2,,EnE_1, E_2, \dots, E_n).

Critical Assumption: For these formulations to hold, the set of hypotheses H1,H2,,HmH_1, H_2, \dots, H_m as well as the set of evidences E1,E2,,EnE_1, E_2, \dots, E_n must be mutually exclusive and exhaustive.

Case 1: Single Evidence EE and Multiple Hypotheses H1,,HmH_1, \dots, H_m

When a single piece of evidence EE is observed, the posterior probability for hypothesis HiH_i is:

P(HiE)=P(EHi)×P(Hi)k=1mP(EHk)×P(Hk)P(H_i | E) = \frac{P(E | H_i) \times P(H_i)}{\sum_{k=1}^m P(E | H_k) \times P(H_k)}

Case 2: Multiple Evidences E1,,EnE_1, \dots, E_n and Multiple Hypotheses H1,,HmH_1, \dots, H_m

Assuming the evidences are conditionally independent given each hypothesis, the generalized posterior probability is:

P(HiE1E2En)=P(E1Hi)×P(E2Hi)××P(EnHi)×P(Hi)k=1m[P(E1Hk)×P(E2Hk)××P(EnHk)×P(Hk)]P(H_i | E_1 E_2 \dots E_n) = \frac{P(E_1|H_i) \times P(E_2|H_i) \times \dots \times P(E_n|H_i) \times P(H_i)}{\sum_{k=1}^m \left[ P(E_1|H_k) \times P(E_2|H_k) \times \dots \times P(E_n|H_k) \times P(H_k) \right]}


Step-by-Step Simulation: Updating Beliefs with Incoming Evidence

Let's walk through a concrete numerical example. Suppose a system has three possible hypotheses (H1,H2,H3H_1, H_2, H_3) and can observe three pieces of evidence (E1,E2,E3E_1, E_2, E_3).

Prior and Conditional Probabilities Table:

ProbabilitiesHypothesis H1H_1Hypothesis H2H_2Hypothesis H3H_3
Prior P(Hi)P(H_i)0.400.400.350.350.250.25
P(E1Hi)P(E_1 \| H_i)0.30.30.80.80.50.5
P(E2Hi)P(E_2 \| H_i)0.90.90.00.00.70.7
P(E3Hi)P(E_3 \| H_i)0.60.60.70.70.90.9

We will observe evidences one by one and update our beliefs dynamically.

Step 1: Observing Evidence E3E_3

When E3E_3 is observed, we compute the updated probability for each hypothesis.

  • Denominator (Marginal Likelihood P(E3)P(E_3)): P(E3)=k=13P(E3Hk)P(Hk)=(0.6×0.40)+(0.7×0.35)+(0.9×0.25)P(E_3) = \sum_{k=1}^3 P(E_3 | H_k) P(H_k) = (0.6 \times 0.40) + (0.7 \times 0.35) + (0.9 \times 0.25) P(E3)=0.240+0.245+0.225=0.710P(E_3) = 0.240 + 0.245 + 0.225 = 0.710

  • Updated Posteriors P(HiE3)P(H_i | E_3):

    • P(H1E3)=0.6×0.400.7100.34P(H_1 | E_3) = \frac{0.6 \times 0.40}{0.710} \approx \mathbf{0.34}
    • P(H2E3)=0.7×0.350.7100.34P(H_2 | E_3) = \frac{0.7 \times 0.35}{0.710} \approx \mathbf{0.34}
    • P(H3E3)=0.9×0.250.7100.32P(H_3 | E_3) = \frac{0.9 \times 0.25}{0.710} \approx \mathbf{0.32}

Belief Shift: After observing E3E_3, the belief in H1H_1 decreases slightly (from 0.400.40 to 0.340.34), while the belief in H3H_3 increases (from 0.250.25 to 0.320.32). H1H_1 and H2H_2 are now tied.

Step 2: Observing Evidence E1E_1 (in addition to E3E_3)

Now we receive E1E_1 and update the beliefs using joint evidence E1E3E_1 E_3:

  • Denominator P(E1E3)P(E_1 E_3): P(E1E3)=k=13P(E1Hk)P(E3Hk)P(Hk)=(0.3×0.6×0.40)+(0.8×0.7×0.35)+(0.5×0.9×0.25)P(E_1 E_3) = \sum_{k=1}^3 P(E_1 | H_k) P(E_3 | H_k) P(H_k) = (0.3 \times 0.6 \times 0.40) + (0.8 \times 0.7 \times 0.35) + (0.5 \times 0.9 \times 0.25) P(E1E3)=0.072+0.196+0.1125=0.3805P(E_1 E_3) = 0.072 + 0.196 + 0.1125 = 0.3805

  • Updated Posteriors P(HiE1E3)P(H_i | E_1 E_3):

    • P(H1E1E3)=0.0720.38050.19P(H_1 | E_1 E_3) = \frac{0.072}{0.3805} \approx \mathbf{0.19}
    • P(H2E1E3)=0.1960.38050.52P(H_2 | E_1 E_3) = \frac{0.196}{0.3805} \approx \mathbf{0.52}
    • P(H3E1E3)=0.11250.38050.29P(H_3 | E_1 E_3) = \frac{0.1125}{0.3805} \approx \mathbf{0.29}

Belief Shift: H2H_2 is now considered the most likely hypothesis by far (0.520.52), and belief in H1H_1 has dropped dramatically down to 0.190.19.

Step 3: Observing Evidence E2E_2 (in addition to E1,E3E_1, E_3)

Finally, we observe E2E_2 and update to E1E2E3E_1 E_2 E_3:

  • Denominator P(E1E2E3)P(E_1 E_2 E_3):

    • Note that P(E2H2)=0.0P(E_2 | H_2) = 0.0. Thus, H2H_2 cannot produce evidence E2E_2. P(E1E2E3)=(0.3×0.9×0.6×0.40)+(0.8×0.0×0.7×0.35)+(0.5×0.7×0.9×0.25)P(E_1 E_2 E_3) = (0.3 \times 0.9 \times 0.6 \times 0.40) + (0.8 \times 0.0 \times 0.7 \times 0.35) + (0.5 \times 0.7 \times 0.9 \times 0.25) P(E1E2E3)=0.0648+0.0+0.07875=0.14355P(E_1 E_2 E_3) = 0.0648 + 0.0 + 0.07875 = 0.14355
  • Updated Posteriors P(HiE1E2E3)P(H_i | E_1 E_2 E_3):

    • P(H1E1E2E3)=0.06480.143550.45P(H_1 | E_1 E_2 E_3) = \frac{0.0648}{0.14355} \approx \mathbf{0.45}
    • P(H2E1E2E3)=0.00.14355=0.0P(H_2 | E_1 E_2 E_3) = \frac{0.0}{0.14355} = \mathbf{0.0}
    • P(H3E1E2E3)=0.078750.143550.55P(H_3 | E_1 E_2 E_3) = \frac{0.07875}{0.14355} \approx \mathbf{0.55}

Belief Shift: Because P(E2H2)=0P(E_2 | H_2) = 0, hypothesis H2H_2 is completely abandoned (P=0P=0). H3H_3 emerges as the most likely hypothesis (0.550.55), followed closely by H1H_1 (0.450.45).


Bayesian Networks

A Bayesian Network is a graphical model that represents probabilistic dependencies among a set of random variables. It consists of:

  1. Structure (DAG): A Directed Acyclic Graph where:
    • Nodes: Represent random variables (discrete or continuous).
    • Edges: Directed arrows pointing from parent to child, representing direct influence or causal dependency. Cycles are forbidden to avoid infinite probability calculation loops.
  2. Parameters (CPTs): Each node has an associated Conditional Probability Table (CPT) that quantifies the effects of its parent nodes. If a node has no parents (root node), its CPT reduces to its prior probability distribution.

Reasoning and Inference in Bayesian Networks

Once the network structure and CPTs are defined, we can perform inference—calculating posterior probabilities of target query variables given some observed variables (evidence).

1. Exact Inference Algorithms

Calculate the exact mathematical posterior distribution:

  • Variable Elimination: Evaluates the joint distribution sum by distributing sums over products, avoiding redundant computations.
  • Junction Tree Algorithm: Transforms the DAG into a tree of cliques (clique tree) and uses belief propagation messaging to calculate exact margins.

2. Approximate Inference Algorithms

For highly complex networks with hundreds of variables, exact inference is NP-hard. We use randomized sampling:

  • Direct Sampling: Generates samples starting from root nodes down using prior distributions.
  • Rejection Sampling: Generates direct samples but discards (rejects) any sample that does not match the observed evidence.
  • Likelihood Weighting: Keeps all samples but weights each one by the likelihood of the observed evidence, avoiding the sample waste of rejection sampling.
  • Markov Chain Monte Carlo (MCMC) & Gibbs Sampling: Generates samples by making state transitions in a Markov chain whose stationary distribution matches the network's joint probability distribution.

3. Deterministic Approximations

  • Mean Field Variational Methods: Formulates inference as an optimization problem, approximating the true posterior with a simpler, factorized distribution.
  • Expectation Propagation: Iteratively updates local approximations of factorized distributions.

Influence Diagrams: Extending Bayes Networks for Decision Making

While Bayesian networks model probabilistic dependencies (diagnosis and prediction), Influence Diagrams extend them to model choice and value. They introduce two new types of nodes:

  1. Decision Nodes (Rectangles): Represent actions or choices that the agent can actively choose to perform.
  2. Utility Nodes (Diamonds): Quantify the desirability, reward, or value associated with different outcomes.

By combining probability, choice, and utility, influence diagrams serve as a complete framework for making optimal decisions under uncertainty.

On this page