Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

Probability and Stochastic

Processes
Reza Pulungan

Department of Computer Science and Electronics


Faculty of Mathematics and Natural Sciences
Universitas Gadjah Mada
Yogyakarta

September 20, 2020


Conditional Probability
Definition

set of all people


set of all people
in the
in the worldworld

"
set of MIT
set of UGM
students
students !

set of people
set of people
who live in
who live in
Cambridge
Yogyakarta

What is the probability of event A? What about event B?


What is the probability that someone is a UGM student,
given that/provided that/with the condition that/if she lives
in Yogyakarta?
Reza Pulungan Probability and Stochastic Processes 3
Definition

Such a probability is called conditional probability, with the


general form “what is the probability of an event, given
that/provided that/with the condition that/if another event
happens”?

This kind of probabilities appears often, for instance:


What is the probability that this afternoon is raining, if this
morning is cloudy?
What is the probability of a simultaneous tossing of two dies
produces 10, if each die produces an odd number of pips?
What is the probability that I get a hand of four-of-a-kind, if
in the beginning I was given two Queens?

Reza Pulungan Probability and Stochastic Processes 4


Definition
Contitional probability “event A happens, if event B
happens” is usually denoted by Pr(A | B).
How do we calculate it? Since we are given a condition that
that someone lives in Yogyakarta, we can basically ignore
all other people who do not live in Yogyakarta. Therefore,
all outcomes outside of B are irrelevant in our calculation.
Hence, intuitively, Pr(A | B) is the part of Yogyakarta
residents who are also UGM student.

Definition (Conditional Probability)


Pr(A ∩ B)
Pr(A | B) ::= .
Pr(B)

If Pr(B) = 0, then the conditional probability Pr(A | B) is


undefined.
Reza Pulungan Probability and Stochastic Processes 5
The Four-Step Method

Problem: The Best-Of-Three Hockey Tournament

Assume that a hockey team wins the first game with


probability 1/2.
In the next games, the team’s winning is determined by the
previous game.
If the team won the previous game, it wins the current
game with probability 2/3.
If it lost the previous game, it wins the current game only
with probability 1/3.
What is the probability that the team wins the whole
tournament, if it won the first game?

Reza Pulungan Probability and Stochastic Processes 6


The Four-Step Method

This is a conditional probability problem.

Let A be the event where the team wins the tournament,


and B be the event where the team wins the first game.
Then our objective is to determine the probability Pr(A | B).
We can solve this problem with a similar method to the
method we used in the “normal” probability: with a tree
diagram and the four-step method.

Reza Pulungan Probability and Stochastic Processes 7


Tree Diagram

game 1 game 2 game 3 outcome event A: event B: outcome


win the win probability
series game 1
! !! T T #$&
%$& !
#$& #$& !"! T T #$#'
! #$% " %$&
" !"" T #$(
! %$& "!! T #$(
" #$% !
#$& " #$& "!" #$#'
%$&
" "" #$&
Reza Pulungan Probability and Stochastic Processes 8
Step 1

Determining the Sample Space

The sample space is:

S = {WW , WLW , WLL, LWW , LWL, LL}.

Reza Pulungan Probability and Stochastic Processes 9


Step 2

Defining the Events of Interest

Event A, the team wins the tournament, is:

A = {WW , WLW , LWW }.

Event B, the team wins the first game, is:

B = {WW , WLW , WLL}.

Reza Pulungan Probability and Stochastic Processes 10


Step 3
Computing the Outcome Probabilities

In this part we use the assumptions we previously made to


determine the probabilities of the edges.
In the first game, winning occurs with probability 1/2.
In the subsequent games, winning is determined by the
result of the previous game. With probability 2/3, if the
previous game is won.
The probability of an outcome is the products of the
probabilities of all edges traversed from the root to the
leave representing the outcome.
For instance, the probability of the outcome WLL is:
1 1 2 1
· · = .
2 3 3 9

Reza Pulungan Probability and Stochastic Processes 11


Step 4
Calculating the Probability of the Event

Now, we can calculate the probability of our event of interest:


Pr(A ∩ B)
Pr(A | B) = ,
Pr(B)
Pr({WW , WLW })
= ,
Pr({WW , WLW , WLL})
1/3 + 1/18
= ,
1/3 + 1/18 + 1/9
7
= .
9

Therefore, the team wins the tournament with probability 7/9, if


it won the first game.
Reza Pulungan Probability and Stochastic Processes 12
How Tree Diagrams Work
Why do tree diagrams work? What are their mathematical
justifications?
The answer is conditional probability. The probabilities we
assign to the edges in the tree diagrams are conditional
probabilities.
For instance, consider the path corresponding to the
outcome WW in the previous tree diagram.
The first edge is labeled 1/2, namely the probability that
the team wins the first game.
The second edge is labeled 2/3. This is the probability that
the team wins the second game, provided that it won the
first game.
The question is why do we simply multiply these
probabilities of the edges?

Reza Pulungan Probability and Stochastic Processes 13


How Tree Diagrams Work
The answer is the previous definition of the conditional
probability, which can also be expressed in the following form:
Theorem (Product Rule for 2 Events)
If Pr(E1 ) 6= 0, then:

Pr(E1 ∩ E2 ) = Pr(E1 ) · Pr(E2 | E1 ).

In our previous case, for the outcome WW :


Pr(wins game #1 ∩ wins game #2)
= Pr(wins game #1)
· Pr(wins game #2 | wins game #1),
1 2 1
= · = .
2 3 3

Reza Pulungan Probability and Stochastic Processes 14


How Tree Diagrams Work

The rule can be generalized for n events.


Theorem (Product Rule for n Events)
If Pr(E1 ∩ E2 ∩ · · · ∩ En−1 ) 6= 0, then:

Pr(E1 ∩ E2 ∩ · · · ∩ En ) = Pr(E1 ) · Pr(E2 | E1 )


· Pr(E3 | E1 ∩ E2 ) · · ·
· Pr(En | E1 ∩ E2 ∩ · · · ∩ En−1 ).

Reza Pulungan Probability and Stochastic Processes 15


Medical Test

A disease is infecting 10% of the population. Fortunately, a test


exists to determine whether someone has the disease or not.
However, the test is not perfect:
If someone has the disease, there is a probability of 10%
that the test indicates that he does not have the disease.
This is called false negatives.
If someone does not have the disease, there is a
probability of 30% that the test indicates that he has the
disease. This is called false positives.
Suppose that someone at random is given the test. If the test
produces positive, what is the probability that he has the
disease?

Reza Pulungan Probability and Stochastic Processes 16


Medical Test
The tree diagram of this medical test problem is:

person test result outcome event A: event B: event


has BO probability has BO tests !
A B
positive
pos !"!# T T T
!"#

yes !"$
!"$ neg !"!$ T

!"# pos !"'& T


no
!"%
!"&
neg !"(%

Reza Pulungan Probability and Stochastic Processes 17


Step 1

Determining the Sample Space

The sample space is:

S = {Y ⊕, Y ⊖, N ⊕, N ⊖}.

Reza Pulungan Probability and Stochastic Processes 18


Step 2

Defining the Events of Interest

Event A, that someone has the disease, is:

A = {Y ⊕, Y ⊖}.

Event B, that the test’s result is positive, is:

B = {Y ⊕, N ⊕}.

Reza Pulungan Probability and Stochastic Processes 19


Step 3

Computing the Outcome Probabilities

The probability of each edge and each outcome can be seen in


the given tree diagram.

Reza Pulungan Probability and Stochastic Processes 20


Step 4
Calculating the Probability of Event

Based on the definition of conditional probability, we can


calculate:
Pr(A ∩ B)
Pr(A | B) = ,
Pr(B)
Pr({Y ⊕})
= ,
Pr({Y ⊕, N ⊕})
0.09
= ,
0.09 + 0.27
1
= .
4

Therefore, if the test’s result is positive, only with 25%


probability is that someone has the disease.
Reza Pulungan Probability and Stochastic Processes 21
A Posteriori Probability

Looking closely, the medical test looks suspicious.


When someone is being tested, hasn’t it been clear
whether he has the disease or not, regardless of the test’s
result?
Therefore, statement “if someone’s test result is positive,
then he has a probability of 25% to have the disease”
seems to make little sense.
Nevertheless, this statement is actually make sense. That
statement simply means “25% of people who receive
positive results have the disease”.

Reza Pulungan Probability and Stochastic Processes 22


A Posteriori Probability

Suppose we reverse our question regarding the


best-of-three hockey tournament: “what is the probability
that the team wins the first game, if it wins the whole
tournament?”.
This question seems a bit absurd.
However, this is actually a valid question. Probability
theory does not recognize the order or time of things; only
recognizes events.
In practise, this actually makes sense. Suppose that you
are told that the team wins the whole tournament, but are
not told about further details. From your perspective, it
makes sense to ask whether the team wins the first game.

Reza Pulungan Probability and Stochastic Processes 23


A Posteriori Probability

A conditional probability such as Pr(B | A) is called a posteriori


if event B preceeds event A in time.
The following are several examples of other a posteriori
probabilities:
The probability that this morning is cloud, if we know that
this afternoon is raining.
The probability that in the beginning we are handed 2
Queens in poker, if in the end we get four-of-a-kind.

Reza Pulungan Probability and Stochastic Processes 24


A Posteriori Probability
We calculate the a posteriori probability “the team wins the first
game, if the team wins the whole tournament” in the same
manner as previously described in slide 8 (look at the tree
diagram):
Pr(B ∩ A)
Pr(B | A) = ,
Pr(A)
1/3 + 1/18
= ,
1/3 + 1/18 + 1/9
7
= .
9

This looks suspicious, because Pr(A | B) is also equal to 7/9.


In general, is Pr(A | B) = Pr(B | A)?

The answer is no. In our example, they are equal because


Pr(A) = Pr(B).
Reza Pulungan Probability and Stochastic Processes 25
A Posteriori Probability

The relation between Pr(A | B) and Pr(B | A) can be seen in


the following rule:
Theorem (Bayes’s Rule))
If Pr(A) and Pr(B) both are not equal to zero, then:

Pr(A | B) · Pr(B)
Pr(B | A) = .
Pr(A)

Reza Pulungan Probability and Stochastic Processes 26


Important Identities
Theorem (The Law of Total Probability, One Event)
If Pr(E ) and Pr(Ē ) both are not equal to zero, then:

Pr(A) = Pr(A | E ) · Pr(E ) + Pr(A | Ē ) · Pr(Ē ).

This law can ebe generalized:


Theorem (The Law of Total Probability)
If E1 , · · · , En are disjoint events whose union is equal to the
whole sample space, then:

X
n
Pr(A) = Pr(A | Ei ) · Pr(Ei ).
i =1

Reza Pulungan Probability and Stochastic Processes 27


Important Identities

All probability rules we have seen in the previous chapter still


apply with conditions.
For instance, since we have the rule:

Pr(A ∪ B) = Pr(A) + Pr(B) − Pr(A ∩ B),

then the following rule is also valid:

Pr(A ∪ B | C) = Pr(A | C) + Pr(B | C) − Pr(A ∩ B | C).

Reza Pulungan Probability and Stochastic Processes 28


Important Identities

Proof:
Pr((A ∪ B) ∩ C)
Pr(A ∪ B | C) = ,
Pr(C)
Pr((A ∩ C) ∪ (B ∩ C))
= ,
Pr(C)
Pr(A ∩ C) + Pr(B ∩ C) − Pr(A ∩ B ∩ C)
= ,
Pr(C)
= Pr(A | C) + Pr(B | C) − Pr(A ∩ B | C).

Reza Pulungan Probability and Stochastic Processes 29


Important Identities
Be careful when putting the conditions. The following identity is
not valid:

Pr(A | B ∪ C) = Pr(A | B) + Pr(A | C) − Pr(A | B ∩ C).

The counterexample can be observed in the following figure:

Reza Pulungan Probability and Stochastic Processes 30

You might also like