Approximate Inference
GATE Relevance: Medium
Prerequisites
🎯 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
- Generate a complete sample x = (x1, …, xn) from the BN's prior (top-down, respecting CPTs)
- If the sample is consistent with the evidence e, keep it; otherwise reject it
- Repeat N times
- 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
- Sample non-evidence variables top-down from the BN
- When encountering an evidence variable Ei = ei, fix it to its observed value instead of sampling
- Assign a weight w to the sample: w = ∏ P(ei | parents(Ei))
- 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
- Initialize non-evidence variables to random values (evidence variables fixed)
- Repeat:
- Pick a non-evidence variable Xi
- Sample Xi from P(Xi | Markov_Blanket(Xi)) — only depends on parents, children, and co-parents
- 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
| Method | All samples used? | Handles rare evidence? | Independent samples? |
|---|---|---|---|
| Rejection | No | Poorly | Yes |
| Likelihood Weighting | Yes (weighted) | Better | Yes |
| Gibbs (MCMC) | Yes | Good | No (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)