Sitemap
Persis Tafflin

Persis Tafflin

Technical Writer | Simplifying FinTech & Current Affairs | Business & Tech Student | Post @every Thursday ^_^ | Starting from 14 May '26

The Logic of Uncertainty: How Bayesian Networks Power AI Reasoning

5 min readApr 30, 2026

--

In this blog, we will break down what a Bayesian Network is, walk through a real medical example step by step.

We’ve all come across the term “Bayesian” or “Bayes’ Theorem” in our school grade mathematics.

Just to refresh; at its core, it’s simply: P(A|B) = [P(A) × P(B|A)] / P(B)

Bayesian Networks are among the most useful tools in AI. They help machines reason under uncertainty; much like how we humans update our thinking as we receive new information.

Wherever we turn, we hear the word AI, and it’s being used across every sector — finance, healthcare, business, and education. And all started integrating AI to make our lives easier, save time, and gain better insights as well.

And interestingly, the same formula, which we once studied in our probability chapters, plays a key role in making all of this possible!

Press enter or click to view image in full size
Photo by Shubham Dhage on Unsplash

Bayesian Network:

(Technical definition)

A Bayesian Network is a probabilistic graphical model. It represents a set of variables and their conditional dependencies, using a directed acyclic graph (DAG).

Key definitions of complex terms:

A Bayesian Network is a directed acyclic graph (DAG) where:

• Each node = a random variable (event, symptom, fact)
• Each edge/arrow = a causal or conditional relationship (e.g., TB → Cough means TB causes cough) .
• Each node has a Conditional Probability Table (CPT) — a small table that stores the probability of that event, given what its parent nodes say

(You can see the CPT below -Image 2 under the example)

Feeling complex?

Let’s make it simple!

Now, let’s understand the core mechanism with an example!

A Real-Life Example: Diagnosing Tuberculosis (TB)

Let’s now compare Bayes’ Theorem with this example.

P(A|B)=[ P(A) * P(B|A) ] / P(B)

In plain English, this says: • “What is the chance of A, given that B already happened?” For example: “What is the chance this person has TB, given that they are coughing?” — that is Bayes’ Theorem in action.

Mathematical Calculation :

P(TB)=0.01 // 1% of population has TB

P(COUGH | TB)=0.90 // 90% of TB patients has cough

P(COUGH)=0.20 // 20% of all people has a cough

Applying Bayes Theorem

P(TB|COUGH)=(0.90 * 0.01) / 0.20 =0.045 ;

which implies a 4.5 % chance -which is much higher than the baseline.

Now, also add that the patient has night sweats & weight loss.

The network updates, so the probability jumps to 78%.

This “updating”-adding evidence piece by piece & recalculating is called BAYESIAN INFERENCE.

Structural Mechanism:

Press enter or click to view image in full size
Image 1: This is how the network (structure + probability or model ) looks like

Now let’s observe image 1.

Here,

Nodes(Variables): TB, Cough, Fever, Weight loss

Edges: Symptoms (causal links)

CPTs: They are the “P(COUGH | TB)=0.90” like stuff in the 1st image that are below the variables.

Press enter or click to view image in full size
Image 2: This is what the computed results (inference) looks like.

And the 2nd image shows the probability of TB updates based on observed symptoms.

It uses those CPTs to compute posterior probability P(TB | symptoms).

Note: posterior means : updated probability after seeing evidence(new/other medical records).

I hope that y’all can get the example!

How does the BAYESIAN NETWORK work?

  1. Start with belief:

You begin with an initial guess.

2. See Evidence

You observe symptoms.

3. Update Belief

Get Persis Tafflin’s stories in your inbox

Join Medium for free to get updates from this writer.

Each symptom changes the probability using Bayes’ rule.

  • Cough → small increase
  • Fever → bigger increase
  • Weight loss → very high

This is called belief propagation (one change spreads through the whole network) , as we can see it in the 2nd image

4. Final Output

You get a new probability (Posterior)

E g: P(TB | Symptoms) =0.78

How does a Bayesian network actually learn ?

🔹 Structure learning

Bayesian Networks finds connections!

Not LinkedIn connections 😂!

Let me explain with the same example!
“Does TB affect Fever?” → if Yes →then, draw an arrow.

The network first needs to discover which variables are connected to which.

This is done by feeding it thousands of real data records and using algorithms like PC Algorithm or Hill Climbing to find statistical dependencies between variables.

Note: statistical dependencies: describe relationships where the probability or value of one variable is influenced by another, indicating they are not independent.

PC Algorithm: A constraint-based method that removes unnecessary connections based on data relationships.

Hill Climbing: A score-based optimization method that keeps changing connections to make the model better step-by-step.

🔹 Parameter learning

Once we know who is connected to whom, we need to know how strongly they are connected.

This is done using Maximum Likelihood Estimation (MLE) — which simply learns from data counts

For each case:
→ Count how often an event + its parents occur
→ Divide by how often the parents occur

I.e., the formula is: CPT value = (count of node + parent together) / (count of parent)

Example:
If 100 patients had TB, and 90 of them coughed, then:
→ patients_with_tb = 100 and tb_with_cough = 90

P(Cough | TB) = tb_with_cough / patients_with_tb

P(Cough | TB) = 90 / 100 = 0.90

🔹 Inference

Key: Uses math to update all beliefs using algorithms & evidence, when new data comes.

Once the network is built and trained, you can ask it questions:

“Given this patient has a cough and fever, what is the chance they have TB?”

The network sends this evidence through all its nodes and updates every probability. This is called belief propagation.

Let’s see how it updates.

Some common algorithms are given below. It uses one of these algorithms to complete the process.

  • Variable Elimination
    → Remove unnecessary variables step-by-step
    → Get required probability efficiently

→ Used for smaller networks (exact result)

  • Belief Propagation
    → Nodes pass messages to each other
    → Entire network updates together

→ Works well in simple/tree structures

  • MCMC (Sampling) — Markov Chain Monte Carlo
    → Use random samples when exact math is too hard
    → Approximate the probabilities

→ Used for large/complex networks.

In conclusion;

Bayesian Networks are a combination of math, logic, and real-world reasoning. They start with a simple question — ‘What do I already know?’ , and they keep updating their answer, as new evidence arrives.

In this blog, we’ve covered:

• Bayes’ Theorem — the formula that drives it all

• What a Bayesian Network is — nodes, edges, and CPTs

• A real medical example -TB diagnosis with step-by-step probability updates

• How networks learn — structure learning, parameter learning, and inference

From a simple formula like P(A|B) to diagnose TB with 78% accuracy , Bayesian networks show us that AI is structured and works by evidence-based thinking, taught to a machine.

Literally, I’m wondering about the power of other math formulas I’ve learnt!.

From a thought to why I need to study math for a computer science background, I’ve changed my thought to, computer students need more math to make things efficiently!

Hope that y’all can understand Bayesian Networks with my explanations !

--

--