Naive Bayes Assumption
In naive Bayes, one assumes that
(conditional independence is an example of naive Bayes)
Total number of parameters is linear in the number of conditionally independent effects . We call this ‘naive’ because it is oversimplifying as in many cases the ‘effect’ variables aren’t actually conditionally independent given the cause variable.
Link to original
Bayesian Network
A Bayesian network is a simple, graphical notation for conditional independence assertions => compact specification of full joint distributions.
Link to original
- Each node corresponds to a random variable (discrete or continuous).
- Directed edge from node to node means is parent of . Likewise, is the child.
- Graph is a Directed Acyclic Graph (no directed cycles).
- Each node has a conditional probability that quantifies the effect of the parent nodes.
Example
Weather is independent of other variables. Toothache and Catch are conditionally independent given Cavity.
graph LR; weather; cavity-->toothache; cavity-->catch;
Global Semantics
Full Joint Distribution (Bayesian Network)
We can calculate the full joint distribution as the product of the local conditional distributions:
Link to original
Example: Compute
Compactness
Compactness of Bayes Network
A conditional probability table for Boolean with Boolean parents has rows for the combinations of parent values. Each row requires just one number for for (as we can find the false equivalent by taking ).
If each variable has no more than parents, the complete network requires numbers. This grows linearly with compared to for the full joint distribution.
Link to original
Local semantics
Local semantics of conditional independence
A node is conditionally independent of its non-descendants (e.g. ) given its parents ().
Link to original
Markov Blanket
Each node is conditionally independent of all others given its Markov blanket : parents + children + children’s parents
Formally if is the set of all variables, let be the remaining nodes then .
Link to original
Example
Given the following relationships:
The Markov blanket of is .
Inference tasks
Simple queries: compute posterior marginal Conjunctive queries: Optimal decisions: decision networks include utility information; probabilistic inference required for . Value of information: “which evidence to seek next?” Sensitivity analysis: “which probability values are most critical?” Explanation: “why do I need a new starter motor?”
Simple Queries
We look at a few ways of computing the posterior marginal:
- Enumeration
- Rejection sampling (using prior sampling)
- Likelihood weighting
- Gibbs sampling
Inference by enumeration
Inference by enumeration
Use the structure of the network to tell us which sets of joint probabilities to use. Gives us a slightly intelligent way to sum out variables from the joint without actually constructing the explicit representation.
Link to original
Simple query on burglary network
graph LR; b-->a; e-->a; a-->j; a-->m;We evaluate the expression by going through the variables in order, multiplying CPT entries along the way. At each point, we need to loop through the possible values of the variable.
Enumeration Algorithm


Improving exact approach
- Variable elimination evaluates the enumeration tree bottom up, remembering intermediate values.
- Clustering algorithms can be more efficient for multiple queries: group variables together.
Complexity of exact inference
For singly connected networks:
- Any two nodes are connected by at most one undirected path.
- Time and space cost of variable elimination is for parents, values.
For multiply connected networks:
- Exponential time and space complexity (even when no. of parents of node are bounded)
- Inference is NP-hard
Prior sampling
Prior Sampling
We use a stochastic simulation, taking random samples from the network.
We repeat this process many times, and in the case that we try to find , we find the proportion of results that is equal to , i.e. .
The more runs we do, the more accurate the probability.
Link to original
Prior Sampling Algorithm

Rejection sampling
Rejection Sampling
In cases where we want to estimate , we cannot use prior sampling, but we can use rejection sampling. We generate samples as in prior sampling and only keep samples where holds to build the estimate, otherwise we ignore the sample.
Link to original
Inefficiency with rejection sampling
For unlikely events, we may have to wait a long time to get enough matching samples. Say we want to estimate :
Rejection sampling would reject of samples. In this case, we want to use likelihood weighting instead.
Rejection Sampling Algorithm

Likelihood weighting
Likelihood Weighting
Likelihood weighting is a version of “importance sampling” where we fix the evidence variable to (we only sample relevant events). We have to weight them with the likelihood that they fit the evidence and use the probabilities we know to do so.
Link to original
Example of likelihood weighting
Consider we have the network:
We want to establish . We pick a variable ordering, e.g. Cloudy, Sprinkler, Rain, WetGrass. Set the weight and deal with each variable in order:
- Cloudy is an evidence variable with the value true so:
- Sprinkler is not an evidence variable, so we sample a value like we did with prior sampling. Let’s assume this returns false, remains the same.
- Rain is not an evidence variable, so we sample a value like we did with prior sampling. Let’s assume this returns true, remains the same.
- WetGrass is an evidence variable with the value true so:
Hence we are left with Cloudy, Rain, WetGrass being true and Sprinkler being false. So we have the event with the weight .
To find a probability we tally up all relevant events weighted with their weights. We would tally the event we found just now under .
Likelihood Algorithm

Gibbs sampling
Gibbs Sampling
Gibbs Sampling is a different approach to sampling where we generate samples by making a random change to the previous sample.
Link to original
- Select an arbitrary state in the Bayesian network. Pick state with evidence variables fixed at observed values. e.g. if we know Cloudy is true, we pick that.
- Generate next state by randomly sampling from a non-evidence value.
- Do sampling conditional on current values of Markov blanket.
Example of Gibbs sampling
Consider the query :
- Evidence variables are fixed to their observed values.
- Non-evidence variables are initialised randomly: Cloudy = true, Rain = false
Initial state is .
First we sample Cloudy given the current state of its Markov blanket. Markov blanket is Sprinkler and Rain. So we sample from . Suppose we get , the new state is:
Next we sample Rain, and repeat for both variables. Each state visited contributes to our estimate for
Say we visit 80 states, and in 20 of those Cloudy is true and the rest false. Therefore:
Sampling variables given state of Markov blanket
For a value of a variable :
where is the Markov blanket of .







