1. Monte Carlo estimates and prior sampling
When exact inference is too costly, we estimate probabilities from random samples. If samples have , the estimate is . By the law of large numbers it converges to the true value (the estimator is consistent), and its standard error falls like : to halve the error you need four times as many samples.
Prior (ancestral, direct) sampling generates one complete sample from the network's joint distribution:
- Order the nodes topologically (parents before children).
- For each node, look up the CPT row for the sampled values of its parents and draw its value from that row.
To draw a binary variable with from a uniform random number , set if , else . (Read the question for its convention; some use or the other branch first.)
The probability of generating a full assignment is exactly , the joint probability. So the fraction of samples matching any event estimates its probability. Prior sampling handles queries with no evidence.