Likelihood Weighting — importance sampling for approximate inference.
Generates samples forward through the network (topological order), weights each sample by likelihood of evidence.
P(query | evidence) ≈ Σ w_i · I(query=sample) / Σ w_i
— raw CPTs for sampling
— topological order
— parent mapping
— query variable
— observed values
— number of samples (default 10000)
Optional
— optional seed
posterior distribution with effective sample size
Likelihood Weighting — importance sampling for approximate inference.
Generates samples forward through the network (topological order), weights each sample by likelihood of evidence.
P(query | evidence) ≈ Σ w_i · I(query=sample) / Σ w_i