AAI Module 2 Notes
AAI Module 2 Notes
AAI Module 2 Notes
Module 2
Uncertainty in AI
• The uncertainty of an agent in AI typically refers to the lack of perfect knowledge or confidence in
the outcomes or states of the environment that the AI agent is interacting with.
• Uncertainty can arise from various sources, and managing it is a crucial aspect of designing intelligent
systems. Here are some common sources of uncertainty in AI:
o Agents often operate in environments where they do not have complete information. They
must make decisions based on partial or imperfect data.
o Sensors used by AI agents to perceive the environment may provide inaccurate or noisy
information. This can lead to uncertainty about the true state of the environment.
o In many real-world scenarios, agents do not have access to the full state of the environment.
They must make decisions based on a partial view, which introduces uncertainty about the
hidden or unobserved parts of the environment.
o The models used by AI agents to represent the environment may not perfectly capture the
underlying dynamics. Modelling errors can lead to uncertainty in predictions and decision-
making.
Example:
Consider an example of uncertain reasoning: diagnosing a dental patient’s toothache.
Consider the following simple rule:
Toothache ⇒ Cavity
The problem is that this rule is wrong. Not all patients with toothaches have cavities; some of them
have gum disease, an abscess, or one of several other problems:
Toothache ⇒ Cavity ∨ GumProblem ∨ Abscess . . .
In order to make the rule true, we have to add an almost unlimited list of possible problems. We
could try turning the rule into a causal rule:
Cavity ⇒ Toothache
But this rule is not right either; not all cavities cause pain.
The only way to fix the rule is to make it logically exhaustive: to augment the left-hand side with all
the qualifications required for a cavity to cause a toothache.
Probabilistic Reasoning in AI
• Probabilistic reasoning in AI involves the use of probability theory to represent and manipulate
uncertain information. This approach is particularly useful when dealing with uncertain or incomplete
data in real-world applications.
• Probabilistic models provide a framework for reasoning under uncertainty, enabling AI systems to
make informed decisions in the face of incomplete or noisy information.
• In probabilistic reasoning, we combine probability theory with logic to handle the uncertainty.
• In the real world, there are lots of scenarios, where the certainty of something is not confirmed, such
as "It will rain today," "behaviour of someone for some situations," "A match between two teams or
two players." These are probable sentences for which we can assume that it will happen but not sure
about it, so here we use probabilistic reasoning.
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 1
Need of probabilistic reasoning in AI:
Probability
• Probability can be defined as a chance that an uncertain event will occur. It is the numerical measure
of the likelihood that an event will occur.
• The value of probability always remains between 0 and 1 that represent ideal uncertainties.
• We can find the probability of an uncertain event by using the below formula.
Conditional probability
• Conditional probability is a probability of occurring an event when another event has already
happened.
• Let's suppose, we want to calculate the event A when event B has already occurred, "the probability
of A under the conditions of B", it can be written as:
Example:
In a class, there are 70% of the students who like English and 40% of the students who likes English and
mathematics, and then what is the percent of students those who like English also like mathematics?
Solution:
• Hence, 57% are the students who like English also like Mathematics.
Bayes’ Theorem
• Bayes' theorem is also known as Bayes' rule, Bayes' law, or Bayesian reasoning, determines the
probability of an event with uncertain knowledge.
• Bayes' Theorem is named after the Thomas Bayes. It describes how to update the probability of a
hypothesis based on new evidence.
• The theorem is expressed mathematically as:
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 2
• P(A∣B): This is the posterior probability of event A given that event B has occurred. In other words,
it's the probability of A after taking into account the evidence B.
• P(B∣A): This is the likelihood of event B occurring given that event A has occurred. It describes
how well the evidence B supports the hypothesis A.
• P(A): This is the prior probability of event A, i.e., the probability of A occurring before considering
the evidence B.
• P(B): This is the prior probability of event B, i.e., the probability of B occurring without any
knowledge of A.
• Medical Diagnosis: Bayes’ theorem is used in medical diagnosis to calculate the probability of a
disease given certain symptoms or test results. It helps doctors make informed decisions about the
likelihood of a patient having a particular condition.
• Spam Filtering: In email spam filtering, Bayes’ theorem is employed to calculate the probability that
an email is spam given certain keywords or characteristics. This helps in distinguishing between
legitimate and spam emails.
• Machine Learning: Bayesian inference is a key component in machine learning, particularly in
probabilistic models. It is used for updating beliefs about model parameters as new data becomes
available, leading to more accurate predictions.
• Finance and Investment: Bayes’ theorem is applied in finance for risk assessment, portfolio
optimization, and predicting market trends. It helps in updating probabilities based on new market
information.
• Weather Forecasting: Bayes’ theorem is used in weather forecasting to update predictions based on
new climate data. It allows meteorologists to continuously refine and improve weather forecasts.
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 3
Problem:
From a standard deck of playing cards, a single card is drawn. The probability that the card is king is 4/52,
then calculate posterior probability P(King|Face), which means the drawn face card is a king card.
Solution:
• Let:
o K: The drawn card is a king.
o F: The drawn card is a face card (king, queen, or jack).
• The probability of drawing a king, P(K), is given as 4/52, because there are four kings in a standard
deck, and there are 52 cards in total.
• The probability of drawing a face card, P(F), is the probability of drawing a king, queen, or jack. There
are 4 of each in a standard deck, so P(F)=12/52.
• Now, Bayes' Theorem is given by:
o P(F∣K) is the probability of drawing a face card given that it is a king. Since every king is also a
face card, P(F∣K)=1.
o P(K) is the probability of drawing a king.
o P(F) is the probability of drawing a face card.
• Now, substitute these values into the formula:
• So, using Bayes' Theorem, the posterior probability that the drawn face card is a king is 1/3.
Problem:
In a survey among a group of students, 70% play football, 60% play basketball, and 40% play both sports. If
a student is chosen at random and it is known that the student plays basketball, what is the probability that
the student also plays football?
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 4
• So, the probability that a randomly chosen student plays football given that the student plays
basketball is 2/3.
Problem:
In a deck of 52 playing cards, 4 cards are drawn without replacement. What is the probability that all 4 cards
are ace cards, given that the first card drawn is an ace?
Problem:
There are two bags, one of which contains 3 black and 4 white balls while the other contains 4 black
and 3 white balls. A die is thrown. If it shows up 1 or 3, a ball is taken from the 1st bag; but it shows up any
other number, a ball is chosen from the second bag. Find the probability of choosing a black ball.
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 5
Problem:
Bag A contains 3 white ball and 2 black ball, bag B contains 3 white ball and 4 black ball and bag C contains
4 white ball and 5 black balls. If a white ball is chosen find the probability that it is chosen from bag B.
Problem:
An insurance company has insured 4000 doctors, 8000 teachers and 12000 businessmen. The chances of a
doctor, teacher and businessman dying before the age of 58 is 0.01, 0.03 and 0.05, respectively. If one of the
insured people dies before 58, find the probability that he is a doctor.
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 6
Problem:
In a neighbourhood, 90% children were falling sick due to flu and 10% due to measles. The probability of
observing rashes for measles is 0.95 and for flu is 0.08. If a child develops rashes, find the child’s probability
of having flu.
Problem:
There are three identical cards except that both the sides of the first card is coloured red, both sides of the
second card is coloured blue and for the third card one side is coloured red and the other side is blue. One
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 7
card is randomly selected among these three cards and put down, visible side of the card is red. What is the
probability that the other side is blue?
Problem:
Three urns are there containing white and black balls; first urn has 3 white and 2 black balls; second urn has
2 white and 3 black balls and third urn has 4 white and 1 black balls. Without any biasing one urn is chosen
from that one ball is chosen randomly which was white. What is probability that it came from the third urn?
Problem:
Three persons A, B and C have applied for a job in a private company. The chance of their selections is in the
ratio 1: 2: 4. The probabilities that A, B and C can introduce changes to improve the profits of the company
are 0.8, 0.5 and 0.3, respectively. If the change does not take place, find the probability that it is due to the
appointment of C.
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 8
Problem:
A man is known to speak the truth 2 out of 3 times. He throws a dice and reports that the number obtained
is a four. Find the probability that the number obtained is actually a four.
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 9
Basic Probability Notation
Independence
• In probability theory, independence is a key concept that describes the relationship between two or
more events or random variables.
• Two events or random variables are considered independent if the occurrence or non-occurrence of
one does not affect the occurrence of the other. Independence is a fundamental concept with various
applications in probability and statistics.
• Independence is a powerful concept that simplifies the analysis of complex systems and allows for
more straightforward calculations of probabilities in various scenarios.
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 10
Wumpus World in Artificial intelligence
• The Wumpus World’s agent is an example of a knowledge-based agent that represents Knowledge
representation, reasoning and planning.
• The Wumpus world is a cave with 16 rooms (4×4). Each room is connected to others through
walkways (no rooms are connected diagonally).
• We have a knowledge-based agent who will go forward in this world. The knowledge-based agent
starts from Room [1, 1].
• The cave has some pits, a treasure and a beast named Wumpus. The Wumpus cannot move but eats
the one who enters its room.
• The exciting thing with this cave is that in one room there is a possibility of finding a heap of gold. So,
the agent goal is to find the gold and climb out the cave without fallen into Pits or eaten by Wumpus.
• If the agent enters the pit, it gets stuck there. The agent is rewarded, when the goal conditions are
met. The agent is penalized, when it falls into a pit or being eaten by the Wumpus.
• There are also some components which can help the agent to navigate the cave. These components
are given as follows:
o The rooms adjacent to the Wumpus room are smelly, so that it would have some stench.
o The room adjacent to PITs has a breeze, so if the agent reaches near to PIT, then he will
perceive the breeze.
o There will be glitter in the room if and only if the room has gold.
o The agent is given one arrow which it can use to kill the wumpus when facing it (Wumpus
screams when it is killed).
• Performance measure:
o Agent gets the gold and return back safe = +1000 points
o Agent dies = -1000 points
o Each move of the agent = -1 point
o Agent uses the arrow = -10 points
• Environment:
o A cave with 16(4×4) rooms
o Rooms adjacent (not diagonally) to the Wumpus are stinking
o Rooms adjacent (not diagonally) to the pit are breezy
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 11
o The room with the gold glitters
o Agent’s initial position - Room [1, 1] and facing right side
o Location of Wumpus, gold and 3 pits can be anywhere, except in Room [1, 1].
• Actuators:
Devices that allow the agent to perform the following actions in the environment.
o Move forward
o Turn right
o Turn left
o Shoot
o Grab
o Release
• Sensors:
Devices which help the agent in sensing the following from the environment.
o Breeze
o Stench
o Glitter
o Scream (When the Wumpus is killed)
o Bump (when the agent hits a wall)
Step 1:
• Initially, the agent is in the first room or on the square [1,1], and we already know that this room is
safe for the agent, so to represent that room is safe we will add symbol OK.
• Symbol A is used to represent agent, symbol B for the breeze, G for Glitter or gold, V for the visited
room, P for pits, W for Wumpus.
• At Room [1,1] agent does not feel any breeze or any Stench which means the adjacent squares are
also OK.
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 12
Step 2:
• Now agent needs to move forward, so it will either move to [1, 2], or [2,1]. Let's suppose agent moves
to the room [2, 1], at this room agent perceives some breeze which means Pit is around this room.
• The pit can be in [3, 1], or [2,2], so we will add symbol “P? “.
• Now agent will stop and think and will not make any harmful move. The agent will go back to the [1,
1] room.
• The room [1,1], and [2,1] are visited by the agent, so we will use symbol V to represent the visited
squares.
Step 3:
• At the third step, now agent will move to the room [1,2] which is OK. In the room [1,2] agent perceives
a stench which means there must be a Wumpus nearby.
• But Wumpus cannot be in the room [1,1] as by rules of the game, and also not in [2,2] (Agent had
not detected any stench when he was at [2,1]).
• Therefore, agent infers that Wumpus is in the room [1,3], and in current state, there is no breeze
which means in [2,2] there is no Pit and no Wumpus.
• So, it is safe, and we will mark it OK, and the agent moves further in [2,2].
Step 4:
• At room [2,2], here no stench and no breezes present so let's suppose agent decides to move to [2,3].
At room [2,3] agent perceives glitter, so it should grab the gold and climb out of the cave.
Important Questions
1. Explain the Bayes’ rule and its applications.
2. Three persons A, B and C have applied for a job in a private company. The chance of their selections
is in the ratio 1: 2: 4. The probabilities that A, B and C can introduce changes to improve the profits
of the company are 0.8, 0.5 and 0.3, respectively. If the change does not take place, find the
probability that it is due to the appointment of C.
3. Consider the set of all possible five-card poker hands dealt fairly from a standard deck of fifty-two
cards.
How many atomic events are there in the joint probability distribution (i.e., how many five-card hands
are there)?
What is the probability of each atomic event?
What is the probability of being dealt a royal straight flush? Four of a kind.
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 13
4. A bag contains 4 balls. Two balls are drawn at random without replacement and are found to be blue.
What is the probability that all balls in the bag are blue?
5. Three urns are there containing white and black balls; first urn has 3 white and 2 black balls; second
urn has 2 white and 3 black balls and third urn has 4 white and 1 black balls. Without any biasing one
urn is chosen from that one ball is chosen randomly which was white. What is probability that it came
from the third urn?
6. Explain the Wumpus world problem in Artificial intelligence.
7. What is independence in probability theory.
8. Explain the basic probability notations.
9. All Problems
Dr. Navaneeth Bhaskar, Associate Professor, CSE (Data Science), SCEM Mangalore 14