CSE3013 Module5
CSE3013 Module5
CSE3013 Module5
What is Uncertainty?
It is a state of
Doubt about the future or
About what is the right thing to do.
Examples :
A doctor does not know exactly what is going on inside a patient.
A teacher does not know exactly what a student understands,
A robot does not know what is in a room it left a few minutes ago.
A period of Politician
The way of life in the coastal region.
But consider a situation where we are not sure about whether A is true or not
then we cannot express this statement, this situation is called uncertainty.
Causes of uncertainty :
Information occurred from unreliable sources.
Experimental Errors or Equipment fault
Temperature variation or Climate change.
In the real world, there are lots of scenarios, where the certainty of something is
not confirmed, such as :
"It will rain today"
"Behavior 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.
In PR, There are two ways to solve problems with uncertain knowledge:
Bayes’ rule
Bayesian Statistics
Probability?
It is a chance that an uncertain event will occur.
It is measured numerically (0 or 1) of the likelihood that an event will occur.
We can find the probability of an uncertain event by using the below formula.
Number _of _Desired_Outcomes
Probability _of _Occurance =
Total_Number _of _Outcomes
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:
P(A ∧ B)
P(A|B) =
P(B)
If the probability of ’A’ is given and we need to find the probability of B, then
it will be given as:
P(A ∧ B)
P(B|A) =
P(A)
It can be explained by using the below Venn diagram, where B is occurred event, so
sample space will be reduced to set B, and now we can only calculate event A when
event B is already occurred by dividing the probability of P(A ∧ B) by P(B).
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 : Let, A is an event that a student likes Mathematics and B is an event that
a student likes English.
P(A ∧ B) 0.4
P(A|B) = = = 57%
P(B) 0.7
Hence, 57% are the students who like English also like Mathematics.
Dr. Rabindra Kumar Singh "Artificial Intelligence" 9/ 109
Bayes’ theorem
Bayes’ theorem can be derived using product rule and conditional probability of
event A with known event B:
Here,
P(A|B) is known as posterior, which we need to calculate, and it will be
read as Probability of hypothesis A when we have occurred an evidence B.
P(B|A) is called the likelihood, in which we consider that hypothesis is
true, then we calculate the probability of evidence.
P(A) is called the prior probability, probability of hypothesis before
considering the evidence
P(B) is called marginal probability, pure probability of an evidence.
In the equation (1), in general, we can write P(B) = P(A) ∗ P(B|Ai ), hence
the Bayes’ rule can be written as:
P(Ai ∗ P(B|Ai ))
P(Ai |B) = Pk (4)
i=1
P(Ai ) ∗ P(B|Ai )
Where A1 , A2 , A3 , ........, An is a set of mutually exclusive and exhaustive events.
What is the probability that a patient has diseases meningitis with a stiff neck?
Given Data:
A doctor is aware that disease meningitis causes a patient to have a stiff neck,
and it occurs 80% of the time. He is also aware of some more facts, which are
given as follows:
The Known probability that a patient has meningitis disease is 1/30,000.
The Known probability that a patient has a stiff neck is 2%.
Let a be the proposition that patient has stiff neck and b be the proposition
that patient has meningitis. , so we can calculate the following as:
P(a|b) = 0.8
P(b) = 1/30000
P(a)= .02
1
P(a|b) ∗ P(b) 0.8 ∗ ( 30000 )
P(b|a) = = = 0.001333333
P(a) 0.02
Hence, we can assume that 1 patient out of 750 patients has meningitis disease
with a stiff neck.
Dr. Rabindra Kumar Singh "Artificial Intelligence" 14/ 109
Example-2
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:
P(face|king) ∗ p(king)
P(king|face) = (1)
P(face)
2∗5
P(B|A)∗P(A) 5 8 2 1
P(A|B) = P(B)
= 4 = 4
= 2
8
1∗4
P(A|B)∗P(B) 2 8 2
P(B|A) = P(A)
= 5 = 5
8
Problem :
Consider a boy who has a volleyball tournament on the next day, but today he
feels sick. It is unusual that there is only a 40% chance he would fall sick since
he is a healthy boy. Now, Find the probability of the boy participating in the
tournament. The boy is very much interested in volleyball, so there is a 90%
probability that he would participate in tournaments and 20% that he will fall
sick given that he participates in the tournaments.
Solution : Let
’A’ be a boy participating the tournament = P(A) = 90%.
’B’ be a boy is Sick = P(B) = 40% and
P(B|A) = P(Boy is Sick | Boy participating in the tournament ) = 20%
Then, Finding P(Boy participating in the tournament | Boy is Sick) is :
P(B|A)∗P(A) 0.9∗0.2
Finding the P(A | B) = P(B)
= 0.4
= 0.45
The Given Data set, which consists of 10 data instances with attributes such as
’CGPA’, ’Interactiveness’, Communication Skills’, and ’Practical
Knowledge’, and the Target Variable ’Job Offer’ which is classified as Yes or
No for a student.
Step-1 : Compute Prior Probability for the target feature ’Job Offer’. It has 2
class Yes/No. It is a binary classification Problem.
Given a student instance, need to classify whether ’Job Offer’ = Yes or No.
From the Given DS, the frequency or the number of instances with Job Offer
= ’Yes’ is 7 and Job Offer = ’No’ is 3.
7 3
∴ P(J=’Yes’) = 10
and P(J=’No’) = 10
.
1 CGPA :
Case-1 :P(J=’Y’ | Test Data) = P(J = ’Y’ |C, I, Pk,CS) * P(J=’Y’)/P((Test Data))
Here, we can ignore P(Test Data) in the denominator since it is common for all
cases to be considered.
= P(C ≥ 9|J=’Y’) * P(I=’Y’|J=’Y’) * P(Pk=’Avg’|J=’Y’) * P(Cs=’Gd’|J=’Y’) * P(J = ’Y’)
3 5 1 4 7
= 7
* 7
* 7
* 7
* 10
* = 0.0175
It is used to calculate the next step of the robot when the already
executed step is given.
Bayes’ theorem is helpful in weather forecasting.
It can solve the Monty Hall problem.
Example
Harry installed a new burglar alarm at his home to detect burglary. The alarm reliably
responds at detecting a burglary but also responds for minor earthquakes. Harry has
two neighbors David and Sophia, who have taken a responsibility to inform Harry at
work when they hear the alarm. David always calls Harry when he hears the alarm, but
sometimes he got confused with the phone ringing and calls at that time too. On the
other hand, Sophia likes to listen to high music, so sometimes she misses to hear the
alarm. Here we would like to compute the probability of Burglary Alarm.
Problem: Calculate the probability that alarm has sounded, but there is neither a
burglary, nor an earthquake occurred, and David and Sophia both called the Harry.
Solution:
The network structure is showing that burglary and earthquake is the
parent node of the alarm and directly affecting the probability of alarm’s
going off, but David and Sophia’s calls depend on alarm probability.
Burglary (B)
Earthquake(E)
Alarm(A)
David Calls(D)
Sophia calls(S)
Let’s take the observed probability for the Burglary and earthquake component:
B E P(A=True) P(A=False)
True True 0.94 0.06
True False 0.95 0.04
False True 0.31 0.69
False False 0.001 0.999
Table: CPT for David Calls Depends on ’A’ Table: CPT for Sophia Calls Depends on ’A’
From the formula of joint distribution, we can write the problem statement in
the form of probability distribution:
Hence, a Bayesian network can answer any query about the domain by using
Joint distribution.
Problem-1
Three people A, B, and C have submitted a job application to a private
business. The likelihood of their choices is 1:2:4.The chances that A, B, and C
can implement adjustments to increase the company’s profitability are,
respectively, 0.8, 0.5, and 0.3.Determine the likelihood that the nomination of c
is to blame if the change doesn’t occur.
Problem-2
Four balls are in a bag. Without replacement, two balls are picked at random,
and it is discovered that they are blue. How likely is it that every ball in the
bag will be blue?
Problem-3
90% of the youngsters in one community were sick with the flu, 10% with the
measles, and no other illnesses were present. For measles, the likelihood of
seeing rashes is 0.95, but for the flu, the likelihood is 0.08. Determine the
likelihood that a child will have the flu if they develop rashes.
Problem-4
There are three similar cards, with the exception that the first card has red on
both sides, the second card has blue on both sides, and the third card has a red
side and a blue side. Out of these 3, one card is picked at random and placed
on the table with its red visible side. How likely is it that the other side is blue?
Problem-5
There are three jars with white and black balls in them: the first contains three
white and two black balls, the second has two white and three black balls, and
the third has four white and one black ball. One urn is arbitrarily selected from
those one white ball, without any bias. What is the likelihood that it came
from the three urns?
The agent’s utility depends on the weather and whether it takes an umbrella.
The agent does not get to observe the weather; it only observes the forecast.
The forecast probabilistically depends on the weather.
As part of this network, the designer must specify the domain for each
Random and the Domain for each decision variable.
1 Random variables are:
Weather{norain, rain},
Forecast{sunny, cloudy, rainy}
2 Decision Variables are :
Umbrella{take_it, leave_it}
There is no domain associated with the utility node.
The designer also must specify the probability of the random variables given
their parents.
There is no table specified for the Umbrella decision variable. It is the task of
the planner to determine which value of Umbrella to select, as a function of
the forecast.
Example-3 : Decision Network for Alarm, The agent can receive a report of
people leaving a building and has to decide whether or not to call the fire
department. Before calling, the agent can check for smoke, but this has some
cost associated with it. The utility depends on whether it calls, whether there
is a fire, and the cost associated with checking for smoke.