VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

How Artificial Intelligence AI Works | How Bayesian Networks Update Beliefs With Evidence

Did you know? Seeing a wet pavement changes your opinion about whether it rained. But learning that a nearby sprinkler was switched on may change that opinion again. We revise our beliefs as clues arrive. A computer can perform related calculations, but it needs an explicit way to represent which uncertain events depend on which others.

A Bayesian network is a probabilistic graphical model. Its arrows form a directed acyclic graph (DAG), and each variable has a probability distribution conditioned on its parent variables. The graph helps organise a joint probability distribution without listing every combination as an unrelated number.

Quick answer: define relevant variables → draw an acyclic dependency structure → supply conditional probabilities → observe evidence → calculate updated probabilities → inspect assumptions and uncertainty. A Bayesian network can reason about evidence under a model; arrows alone do not establish real-world cause and effect.

Let’s build a simple fictional pavement example. Every probability is invented for learning the mathematics and must not be mistaken for real weather, sprinkler or insurance statistics.

Bayesian networks in 30 seconds

  • Node: a variable that can take defined values, such as Rain = yes or no.
  • Directed edge: an arrow representing a dependency in the model’s factorisation.
  • Directed acyclic graph: a graph without a directed loop that starts and returns to the same node.
  • Parent: a node with an arrow pointing into another node.
  • Conditional probability table (CPT): probabilities for a variable given every relevant combination of its parents.
  • Prior: a probability assigned before taking account of particular new evidence.
  • Posterior: a probability after conditioning on evidence.
  • Conditional independence: a relationship that permits parts of the full distribution to be factored.
  • Inference: computing probabilities about unobserved variables after evidence is supplied.
  • Intervention: a hypothetical action that changes a variable, requiring a justified causal model to analyse.

Our model: rain, sprinkler and wet pavement

Define three binary variables: R = Rain, S = Sprinkler operating and W = Pavement wet. Each can be yes or no.

We draw two arrows: R → W ← S. In this model, Rain and Sprinkler are parent nodes of Wet. Before conditioning on Wet, we deliberately assume Rain and Sprinkler are independent.

Suppose our invented prior probabilities are P(R = yes) = 0.20 and P(S = yes) = 0.10.

These choices define a teaching world. In real life, irrigation practices may be related to the weather, and ‘wet’ can have other causes. The model’s graph would then need revision.

Step 1: Every node needs a clear definition

Rain = yes could mean measurable rain in the previous hour, any rain during the whole day or a forecast of rain tomorrow. Those are different events and need different probabilities.

Wet pavement also needs a measurement rule. Does a puddle count? Does surface moisture count? Are we checking a specific location and time?

Undefined variables create false precision. A network cannot repair a vague label merely because it displays an impressive diagram.

Step 2: Why the graph must be acyclic

A Bayesian network encodes a factorisation over variables ordered in a graph without directed cycles. A chain A → B → C is permitted, as is the converging pattern R → W ← S.

A loop A → B → C → A is not a DAG and cannot be used unchanged as the structure of an ordinary static Bayesian network.

If a physical system contains feedback over time, one can model different time steps explicitly or use other probabilistic frameworks. Simply drawing a cycle and calling it a Bayesian network bypasses the required mathematical structure.

Step 3: Write the prior probabilities

With Rain yes probability 0.20, Rain no has probability 0.80. With Sprinkler yes probability 0.10, Sprinkler no has probability 0.90.

Each binary variable’s alternatives must sum to one. The independence assumption means the joint probability of any Rain–Sprinkler combination is the product of the two appropriate priors.

For example, Rain yes and Sprinkler yes has probability 0.20 × 0.10 = 0.02 before considering the pavement.

Step 4: Give Wet a conditional probability table

Our toy model uses four values for the probability of a wet pavement, conditional on its two parent variables.

If it rained and the sprinkler ran: P(W = yes | R = yes, S = yes) = 0.99.

If it rained without the sprinkler: P(W = yes | R = yes, S = no) = 0.90.

If the sprinkler ran without rain: P(W = yes | R = no, S = yes) = 0.80.

If there was neither rain nor sprinkler: P(W = yes | R = no, S = no) = 0.01.

Each probability for W = no is its complement to one. For instance, the probability of dry pavement when neither event happened is 0.99.

Step 5: Factor the complete distribution

The model’s joint probability can be written as P(R, S, W) = P(R) × P(S) × P(W | R, S).

The equality follows from this particular graph and its assumptions. It does not claim that the weather and sprinkler are independent in every real neighbourhood.

A larger Bayesian network expresses its joint distribution as the product of the conditional distribution for each node given its parents.

Step 6: Calculate one complete scenario

For Rain yes, Sprinkler yes, Wet yes, multiply the Rain prior, Sprinkler prior and the corresponding Wet probability.

0.20 × 0.10 × 0.99 = 0.0198. So that entire joint scenario has probability 1.98% within our fictional model.

Notice the difference: the 99% value was conditional on two parent events already being true. The 1.98% result represents all three events being true together.

Step 7: Enumerate the other wet-pavement scenarios

Rain yes, Sprinkler no, Wet yes: 0.20 × 0.90 × 0.90 = 0.1620.

Rain no, Sprinkler yes, Wet yes: 0.80 × 0.10 × 0.80 = 0.0640.

Rain no, Sprinkler no, Wet yes: 0.80 × 0.90 × 0.01 = 0.0072.

These four cases cover all possible Rain–Sprinkler combinations when the pavement is observed wet. They do not have to sum to one by themselves because dry-pavement outcomes are not included.

Step 8: Find the probability of observing wet pavement

Add the four wet scenarios: 0.0198 + 0.1620 + 0.0640 + 0.0072 = 0.2530.

So in this fictional model P(W = yes) = 25.3%. This is the denominator we need to condition on the new evidence that the pavement is wet.

This operation is sometimes called marginalisation or summing over unobserved possibilities. It is vital because the model does not know which combination caused the observation.

Step 9: Use Bayes’ rule to update the chance of rain

The Rain yes and Wet yes scenarios are the first two entries: 0.0198 + 0.1620 = 0.1818.

Condition on Wet yes: P(R = yes | W = yes) = 0.1818 / 0.2530 ≈ 0.7186.

The posterior is about 71.9%. Before seeing the pavement, the toy model assigned Rain a 20% prior. After observing Wet, Rain becomes much more likely under the model.

This does not prove rain occurred. The sprinkler and rare other wet-pavement event remain possible explanations.

Step 10: Compute the chance of sprinkler operation

The Sprinkler yes and Wet yes scenarios are 0.0198 + 0.0640 = 0.0838.

Therefore P(S = yes | W = yes) = 0.0838 / 0.2530 ≈ 0.3312, or about 33.1%.

These posteriors do not need to add to one. Rain and Sprinkler are not mutually exclusive events: both could have happened, neither could have happened, or just one could have happened.

Step 11: Experience explaining away

Now suppose we learn that the sprinkler was operating and the pavement is wet. Does that alter the probability of rain? Yes, in this network.

P(R = yes | W = yes, S = yes) = 0.0198 / (0.0198 + 0.0640) ≈ 0.2363, or about 23.6%.

Learning the sprinkler was on provides an alternative explanation for the wet pavement. The probability of Rain falls from about 71.9% given Wet alone to about 23.6% given both Wet and Sprinkler.

This is the classic explaining-away pattern associated with the converging structure R → W ← S. It depends on our prior independence and conditional probability assumptions.

Step 12: What if we instead learn the sprinkler was off?

Condition on Wet yes and Sprinkler no. The Rain yes contribution is 0.1620, while Rain no contributes only 0.0072.

The result is P(R = yes | W = yes, S = no) = 0.1620 / (0.1620 + 0.0072) ≈ 0.9574, about 95.7%.

Both calculations use the same network. The changing evidence changes the posterior. This is how a probabilistic model can update its conclusions without rewriting every relationship from scratch.

Step 13: Why observing a common effect can create dependence

Before observing Wet, our model treats Rain and Sprinkler as independent. In mathematical notation, P(R, S) = P(R)P(S).

After observing their common effect Wet, knowing whether the sprinkler ran changes what we infer about rain. Rain and Sprinkler are now statistically dependent under that conditioning.

This is counterintuitive and important. A variable at which arrows converge is called a collider. Conditioning on a collider or certain of its descendants can open an association that was absent beforehand.

Step 14: Conditional independence makes large models tractable

Consider the chain Clouds → Rain → Wet pavement. Under an appropriate Bayesian network factorisation, knowing Rain may make Clouds irrelevant to predicting Wet, even though Clouds and Wet are associated when Rain is not given.

This is a statement about the model’s conditional independence structure, not a licence to disregard all context in a real weather study.

These independence relations can greatly reduce the number of probabilities that must be specified and can guide efficient inference.

Step 15: A Bayesian network is not automatically a causal diagram

The arrow R → W could be given a causal interpretation if supported by a justified causal model and domain knowledge. However, ordinary Bayesian network structure can also be learned to represent conditional dependencies for prediction.

Observational correlations and a plausible-looking arrow do not by themselves establish an intervention effect. Whether forcing the sprinkler on changes a target outcome in the way predicted requires causal assumptions and appropriate validation.

Do not present every directed probability graph as proof of a cause-and-effect mechanism.

Step 16: Evidence, observation and intervention differ

Observing S = yes means we learned that the sprinkler was operating under its natural data-generating process. Intervening to set S = yes means taking an action that changes the process.

In a fully justified causal graph, these can produce different distributions because intervention changes how the variable is generated. A purely predictive Bayesian network is not sufficient to answer all intervention questions.

For decisions that change schools, medical treatments or public policy, causal claims require substantially stronger evidence than our toy example offers.

Step 17: How the probabilities can be obtained

An expert might specify a small teaching CPT by hand, as we did. A practical system may estimate parameters from observed data, possibly with Bayesian priors or missing-data methods.

Rare combinations can make conditional probability estimates unstable. Data collection bias, inconsistent variable definitions and unrecorded factors may distort the network even when all rows sum correctly.

Parameter fitting should be separated from independent evaluation. A seemingly precise 0.99 value is not trustworthy merely because software printed two decimal places.

Step 18: Structure learning is a separate task

Sometimes analysts already know the network’s dependency structure; sometimes they try to learn it from data through conditional independence tests, scores or other search procedures.

Multiple graphs can encode equivalent observational independence relations, and limited datasets may not identify arrow directions uniquely. A discovered graph therefore requires assumptions and expert scrutiny.

The pgmpy user guide separates structure learning, parameter estimation, probabilistic inference and causal analysis so these tasks are not confused.

Step 19: Exact and approximate inference

With only three binary variables, we can enumerate all combinations by hand. In a much larger graph, exact inference can require substantial computation because dependency patterns determine the complexity.

Algorithms such as variable elimination exploit the factorisation. Approximate inference may use sampling when exact computation is too expensive.

A result that converges under a numerical algorithm still depends on model quality. Computational correctness cannot replace accurate data and sensible assumptions.

Step 20: Compare Bayesian networks with Naive Bayes

Naive Bayes is a particular simple probabilistic classifier. Its standard form assumes features are conditionally independent given the class being predicted.

A Bayesian network permits more varied dependencies, including chains, forks and colliders, while still representing conditional probability factors.

Both use probability and conditional relationships. The more complex graph is not necessarily a better classifier; compare models based on data requirements, interpretability, computation and held-out performance.

Step 21: Why probability calibration matters

Even a mathematically valid Bayesian network can make systematically poor probability forecasts if its input distributions are wrong.

Compare predictions with later observed frequencies where suitable, test across relevant conditions and track whether data or system behaviour changes. A probability such as 71.9% communicates a model estimate, not an independent measurement of reality.

The broader confidence and uncertainty explainer introduces why numbers that look certain need their own reliability checks.

Step 22: Where Bayesian networks may be useful

Fault diagnosis: combining several sensor clues under an explicit dependency model.

Scientific modelling: organising uncertain relationships between measured variables.

Decision-support research: asking how beliefs shift when new observations become available, with independent oversight.

Education: teaching Bayes’ rule, conditional probability, graphs and the discipline of stating assumptions.

For sensitive decisions about individuals, avoid pretending a probabilistic model can classify a person’s future or ability with certainty. Input quality, fairness and independent human judgement remain important.

Five errors worth avoiding

  • ‘An arrow proves causation.’ No. A predictive dependency graph does not automatically establish intervention effects.
  • ‘Rain and sprinkler posteriors must add to 100%.’ No. Both events can happen together.
  • ‘Conditioning can only reduce uncertainty in one direction.’ No. New evidence can raise or lower a specific posterior.
  • ‘Any network with a cycle is an ordinary Bayesian network.’ No. The directed graphical structure must be acyclic.
  • ‘The computer inferred real weather statistics.’ No. Our numbers were fictional teaching assumptions.

Try it: the wet-pavement probability puzzle

  1. Draw R → W ← S and set P(R) = 0.20 and P(S) = 0.10 independently.
  2. Enter P(W | R,S) = 0.99, P(W | R,not S) = 0.90, P(W | not R,S) = 0.80 and P(W | not R,not S) = 0.01.
  3. Multiply the four prior-combination probabilities by their wet conditional probabilities to get 0.0198, 0.1620, 0.0640 and 0.0072.
  4. Add these values to obtain P(W) = 0.2530.
  5. Add both Rain-yes scenarios and divide by P(W) to obtain P(R | W) ≈ 0.7186.
  6. Condition further on Sprinkler yes to obtain P(R | W,S) ≈ 0.2363.
  7. Explain the difference in words: evidence that a second explanation is present weakens the inferred need for rain under this model.

Frequently asked questions

What is a Bayesian network?

A directed acyclic graphical model representing a joint probability distribution through conditional probabilities attached to each node.

What does a node represent?

A variable with a clearly defined set of possible values, such as a yes-or-no observation or a numerical quantity in an appropriate model.

What is explaining away?

A pattern in which learning one possible explanation of an observed common effect lowers the probability of another explanation under the model.

Is a Bayesian network the same as Naive Bayes?

No. Naive Bayes is a specific classifier with strong conditional-independence assumptions; Bayesian networks can express richer dependency patterns.

Can Bayesian networks prove causes?

Not by themselves. Causal interpretation requires extra assumptions, relevant evidence and valid intervention reasoning.

Why should students learn them?

They show how diagrams, multiplication, addition and conditional probabilities combine into a rigorous method for updating beliefs.

Your one-minute takeaway

Bayesian networks use a directed acyclic graph and conditional probability tables to describe uncertain relationships. You calculate a joint probability by multiplying local factors, then update beliefs by conditioning on new evidence. The mathematics is transparent when assumptions are stated—but probability arrows and persuasive-looking posteriors do not automatically prove causation.

Trusted reading and connected articles

Discover more from eduKate Singapore

Subscribe now to keep reading and get access to the full archive.

Continue reading