Approximate Inference

GATE Relevance: Medium

🎯 Learning Objectives

  • Understand why approximate inference is necessary
  • Describe rejection sampling and its limitations
  • Explain likelihood weighting as an improvement
  • Outline Gibbs sampling (MCMC) for Bayesian networks

1. Why Approximate Inference?

Exact inference in general Bayesian networks is #P-hard. For multiply-connected networks with many variables, exact methods become intractable. Approximate methods trade exactness for tractability, providing answers that are close to correct with high probability.

2. Rejection Sampling

Rejection Sampling Algorithm

  1. Generate a complete sample x = (x1, …, xn) from the BN's prior (top-down, respecting CPTs)
  2. If the sample is consistent with the evidence e, keep it; otherwise reject it
  3. Repeat N times
  4. Estimate P(Q | e) from the distribution of Q values in accepted samples

Properties

  • Consistent: Converges to true posterior as N → ∞
  • Problem: If evidence is unlikely, most samples are rejected — very wasteful. For rare evidence, need exponentially many samples.

3. Likelihood Weighting

Likelihood Weighting Algorithm

  1. Sample non-evidence variables top-down from the BN
  2. When encountering an evidence variable Ei = ei, fix it to its observed value instead of sampling
  3. Assign a weight w to the sample: w = ∏ P(ei | parents(Ei))
  4. Use weighted counts to estimate the posterior

Example

Alarm network: evidence j=T, m=T. When sampling, we fix J=T and M=T. Weight = P(J=T|a) × P(M=T|a) where a is the sampled alarm value.

Advantages over Rejection Sampling

  • No samples are rejected — every sample contributes
  • Much more efficient when evidence is unlikely
  • Limitation: Evidence nodes at the bottom of the network may cause weight variance issues

4. Gibbs Sampling (MCMC)

Gibbs Sampling Algorithm

  1. Initialize non-evidence variables to random values (evidence variables fixed)
  2. Repeat:
    • Pick a non-evidence variable Xi
    • Sample Xi from P(Xi | Markov_Blanket(Xi)) — only depends on parents, children, and co-parents
  3. After a burn-in period, use the samples to estimate the posterior

Convergence

Under mild conditions (ergodicity), Gibbs sampling converges to the true posterior distribution. The samples form a Markov chain whose stationary distribution is the target posterior — hence "Markov Chain Monte Carlo" (MCMC).

Comparison of Methods

MethodAll samples used?Handles rare evidence?Independent samples?
RejectionNoPoorlyYes
Likelihood WeightingYes (weighted)BetterYes
Gibbs (MCMC)YesGoodNo (correlated)

Summary

  • Approximate inference is necessary when exact inference is intractable
  • Rejection sampling: simple but wasteful for rare evidence
  • Likelihood weighting: no rejection, uses weights for evidence nodes
  • Gibbs sampling: MCMC method, samples from Markov blanket conditionals
  • All methods are consistent (converge to true answer with enough samples)