Artificial Intelligence (AI)
Module 5
Probabilistic Reasoning
Introduction to Uncertainty in AI: In many real-world AI problems, the environment and
data are incomplete, noisy, or uncertain.
Examples:
• A medical diagnosis system cannot be 100% sure of a disease based only on
symptoms.
• A robot may not always perceive objects correctly due to sensor noise.
Hence, probabilistic reasoning is used to handle uncertainty systematically. It allows the AI
system to compute how likely a hypothesis or event is true given some evidence.
Basic Probability Concepts
Term Meaning Example
Experiment Any process that leads to an outcome Tossing a coin
Sample Space (S) Set of all possible outcomes {Head, Tail}
Event (E) A subset of S “Head occurs”
Probability (P(E)) Measure of likelihood of event E P(Head) = 0.5
Conditional Probability:
𝑃(𝐴 ∩ 𝐵)
𝑃( 𝐴 ∣ 𝐵 ) =
𝑃(𝐵)
Meaning: Probability that A is true given that B is already known to be true.
Example:
• A = “It rains”, B = “Sky is cloudy.”
• P(A|B) = Probability of rain given that the sky is cloudy.
Bayes’ Theorem (Bayesian Learning Foundation): Bayes’ theorem provides a mathematical
rule for updating beliefs based on new evidence.
𝑃(𝐸 ∣ 𝐻) ⋅ 𝑃(𝐻)
𝑃( 𝐻 ∣ 𝐸 ) =
𝑃(𝐸)
Where:
• H = Hypothesis (e.g., “Patient has disease D”)
• E = Evidence (e.g., “Test result is positive”)
• P(H) = Prior probability of hypothesis
• P(E∣H) = Likelihood of observing evidence if hypothesis true
• P(H∣E) = Posterior probability (updated belief after seeing evidence)
Example: Medical Diagnosis:
• Disease (D): occurs in 1% of population → P(D) = 0.01
• Test gives positive result in 99% of diseased cases → P(Pos|D) = 0.99
• Test gives false positive in 5% of healthy cases → P(Pos|¬D) = 0.05
Compute: P(D|Pos) → probability that patient actually has the disease given a positive test.
𝑃(𝑃𝑜𝑠 ∣ 𝐷)𝑃(𝐷)
𝑃( 𝐷 ∣ 𝑃𝑜𝑠 ) =
𝑃(𝑃𝑜𝑠 ∣ 𝐷)𝑃(𝐷) + 𝑃(𝑃𝑜𝑠 ∣ ¬𝐷)𝑃(¬𝐷)
0.99 × 0.01
𝑃( 𝐷 ∣ 𝑃𝑜𝑠 ) = ≈ 0.167
(0.99 × 0.01) + (0.05 × 0.99)
Even though the test is 99% accurate, the real chance that the patient is sick after a positive
result is only ~16.7%, showing how prior probability matters.
Bayesian Networks (Belief Networks)
A Bayesian Network is a graphical model that represents probabilistic relationships among a
set of variables.
• Nodes → Random variables
• Edges → Conditional dependencies
• Each node has a Conditional Probability Table (CPT)
Example: Rain → WetGrass ← Sprinkler
This network expresses:
• The grass can be wet if it rains or if the sprinkler is on.
• WetGrass depends on both Rain and Sprinkler.
Joint Probability Distribution:
𝑃(𝑅𝑎𝑖𝑛, 𝑆𝑝𝑟𝑖𝑛𝑘𝑙𝑒𝑟, 𝑊𝑒𝑡𝐺𝑟𝑎𝑠𝑠) = 𝑃(𝑅𝑎𝑖𝑛) × 𝑃(𝑆𝑝𝑟𝑖𝑛𝑘𝑙𝑒𝑟) ×
𝑃(𝑊𝑒𝑡𝐺𝑟𝑎𝑠𝑠 ∣ 𝑅𝑎𝑖𝑛, 𝑆𝑝𝑟𝑖𝑛𝑘𝑙𝑒𝑟)
Inference Example:
Compute 𝑃(𝑅𝑎𝑖𝑛 ∣ 𝑊𝑒𝑡𝐺𝑟𝑎𝑠𝑠 = 𝑇𝑟𝑢𝑒): Probability that it rained given grass is wet.
Fuzzy Logic and Fuzzy Sets
Motivation:
• Classical logic assigns crisp truth values: True (1) or False (0).
• But many real-world concepts are vague, e.g., “the day is hot”, “the speed is fast”.
• Fuzzy logic allows partial truth values between 0 and 1.
Temperature Fuzzy value (µHot)
25°C 0.1
30°C 0.5
40°C 1.0
Fuzzy Set Definition: A fuzzy set A in universe U is defined as:
𝐴 = {(𝑥, 𝜇𝐴 (𝑥)) ∣ 𝑥 ∈ 𝑈, 0 ≤ 𝜇𝐴 (𝑥) ≤ 1}
• 𝜇𝐴 (𝑥): membership function that gives degree of belonging.
Example: Let A = “Hot Day”
If µA(35°C) = 0.8 → means 35°C is 80% hot.
Basic Fuzzy Operations:
Operation Formula Description
Union 𝜇𝐴∪𝐵 (𝑥) = max(𝜇𝐴 (𝑥), 𝜇𝐵 (𝑥)) “A or B”
Intersection 𝜇𝐴∩𝐵 (𝑥) = min(𝜇𝐴 (𝑥), 𝜇𝐵 (𝑥)) “A and B”
Complement 𝜇𝐴̅ (𝑥) = 1 − 𝜇𝐴 (𝑥) “Not A”
Fuzzy Inference System (FIS): A Fuzzy system maps inputs → outputs using fuzzy rules.
Example: Temperature Control System
1. Fuzzification: Convert input (e.g., 35°C) to fuzzy sets → “Medium Hot (0.6)”.
2. Rule Base:
o IF temperature is high THEN fan_speed is fast.
o IF temperature is medium THEN fan_speed is moderate.
3. Inference: Combine rules using min-max logic.
4. Defuzzification: Convert fuzzy output to crisp value (e.g., fan speed = 75%).
Methods: Centroid (commonly used), Mean of Maxima, etc.
Natural Language Processing (NLP): NLP is the branch of AI that enables computers to
understand, interpret, and generate human language.
Main Tasks:
Task Description Example
Split text into
Tokenization “AI is fun” → [“AI”, “is”, “fun”]
words/tokens
Part-of-Speech (POS)
Identify grammar role “AI/NN is/VB fun/JJ”
Tagging
Parsing Build syntax tree For sentence structure
Named Entity Recognition Identify names, places, “Elon Musk founded SpaceX” →
(NER) etc. Person, Org
Detect emotion or “This movie is amazing!” →
Sentiment Analysis
polarity Positive
Applications: Chatbots, speech assistants, translation, text summarization, question
answering, etc.
Expert Systems: An Expert System is a computer program designed to simulate the reasoning
and decision-making of a human expert.
Architecture:
1. Knowledge Base (KB):
o Contains domain knowledge (facts + rules).
o Example: “If fever > 102°F and cough = yes → suspect influenza.”
2. Inference Engine:
o Applies logical reasoning to derive conclusions from KB.
o Techniques: Forward chaining, backward chaining.
3. User Interface:
o Allows interaction between user and system.
Example: Medical Expert System
Rule 1: IF fever AND cough THEN flu
Rule 2: IF flu THEN rest and hydration
Inference Example:
• Input: fever = True, cough = True → Output: flu diagnosis + advice.