semester 2010 (june
TRANSCRIPT
Department of Computer Engineering, Faculty of Engineering,Kasetsart University, THAILAND
1st semester 2010 (June – September)
Assoc. Prof. Anan Phonphoem, Ph.D.
Department of Computer Engineering, Faculty of Engineering,
Kasetsart University, THAILAND
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 3
P[☺]
is a function that maps event
in the sample space to real number
From experiment: Roll a dice
Outcomes:
number = 1,2,3,4,5,6
Sample space:
S = {1,2,3,…,6}
Event examples:
E1 = {number < 3} = {1,2}
E2 = {number is odd} = {1,3,5}
P[E1] = 2/6 = 1/3
P[E2] = 3/6 = 1/2
16 June 2010
Axiom 1: For any event A, P[A] 0
Axiom 2: P[S] = 1
Axiom 3: For events A1, A2,…, An of mutual exclusive
events
P[A1A2…An] = P[A1]+P[A2]+…+P[An]
4Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
• If we know P[A] before an experiment
• P[A] 1
• Advanced knowledge almost certainly occur
• P[A] 0
• Advanced knowledge almost certainly not occur
• P[A] ½
• Advanced knowledge maybe occur
• P[A] is a priori probability of A
5Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
• In practice, it maybe impossible to find the
precise outcome of an experiment
• However, if we know that Event B has
occurred
• Probability of A when B occurs can be described
(the outcome of Event A is in set B)
• Still don’t know P[A]
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 616 June 2010
• Notation: P[A|B]
• “Probability of A given B”
• The condition probability of the event A given the occurrence of the event B
• Definition:
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 7
P[A|B] =P[AB]
P[B]
• P[B] > 0
B
AA B
16 June 2010
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 8
S
A
B
P[A|B] =P[AB]
P[B]
P[A|S] =P[AS]
P[S]
P[A]
1=
= P[A]
S
A
B
A
A B
B
A B
S
A
BB
A B
16 June 2010
http://www.fifa.com/worldcup/teams/index.html
What is the probability that
South Korea will win the world
cup ?
What is the probability that
South Korea will win the world
cup, given that all teams in
Europe are withdrawn ?
Assume: all teams are equally likely to win the game
1
32
1
19
Let B1, B2,…,Bn be mutually exclusive events whose union equals sample space S partition of S
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 10
B1 B2B3
B4 Bn…A
i = 1
n
P[A Bi]P[A] =
For any event A
A = AS = A(B1 B2…Bn)
P[A] = P[AB1] + P[AB2] +…+ P[ABn]
Theorem:
16 June 2010
• Let B1, B2,…,Bn be mutually exclusive events whose union equals sample space S
• P[Bi] > 0
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 11
B1 B2B3
B4 Bn…A
P[A] = P[AB1] + P[AB2] +…
P[A] = P[A|B1]P[B1] + P[A|B2]P[B2] +…
i = 1
n
P[A Bi]P[A] = Theorem:
i = 1
n
P[A|Bi]P[Bi]P[A] = Theorem:
16 June 2010
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 12
P[B|A] =P[BA]
P[A]
P[A|B]P[B]
P[A]=
P[A|B] =P[AB]
P[B]
P[B|A]Theorem:P[A|B]P[B]
P[A]=
www.pr-owl.org/basics/probability.php
16 June 2010
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 14
Definition: Event A and B are independent iff
P[AB] = P[A]P[B]
P[A|B] =P[AB]
P[B]
=P[A]P[B]
P[B]
P[B|A] = P[B]
P[A|B] = P[A]
16 June 2010
P[A] = 0.3
P[A|B] = 0.3
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 15
No matter event B occurs or not,
event A is not affected
16 June 2010
16
Independent Disjoint
P[AB] 0 P[AB] = 0
P[AB] = P[A]P[B] P[AB] = P[A]+P[B]
BA
BA
Note: Independent = Disjoint iff P[A]=0 or P[B]=0
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
• The sequence is equally likely
• R1 = The first light was red
• R2 = The second light was red
• G2 = The second light was green
• Are R2 and G2 independent?
• Are R1 and R2 independent?
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 17
1 2 3
• 3 traffic lights, observe a sequence of lights
16 June 2010
• Sample Space:
• S = {rrr, rrg, rgr, rgg, grr, grg, ggr, ggg}
• Are R2 and G2 independent?
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 18
rrr
rrg
grr
grg
rgr
rgg
ggr
ggg
• P[R2]= P[{rrr, rrg, grr, grg}] = 4/8 = ½
• P[G2]= P[{rgr, rgg, ggr, ggg}] = ½
• P[R2G2] = 0
• P[R2]P[G2] = (½)* (½) = ¼
R2 and G2 are not independent
R2 and G2 are disjoint
rrr
rrg
grr
grg
R2
rgr
rgg
ggr
ggg
G2
16 June 2010
• P[R1]= P[{rrr, rrg ,rgr, rgg}] = ½
• P[R2]= P[{rrr, rrg ,grr, grg}] = ½
• P[R1R2] = P[{rrr ,rrg}] = 2/8 = 1/4
• P[R1]P[R2] = (½) * (½) = ¼
R1 and R2 are independent
R1 and R2 are not disjoint
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 19
rrr
rrg
grr
grg
rgr
rgg
ggr
ggg
rrr
rrg
grr
grg
R2
R1
rrr
rrg
rgr
rgg
• Are R1 and R2 independent?
16 June 2010
20
Definition: Event A1,A2 and A3 are independent iff
1) A1 and A2 are independent
2) A2 and A3 are independent
3) A1 and A3 are independent
4) P[A1A2A3] = P[A1] P[A2] P[A3]
Definition: Event A and B are independent iff
P[AB] = P[A] P[B]Is it sufficient ?
P[ABC] = P[A] P[B] P[C]
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty
NO !
16 June 2010
Note:
• Given: P[A] = P[B] = P[C] = 1/5• Given: P[AB] = P[AC] = P[BC] = P[ABC] = 1/25• Independence in pairs (number 1-3) may not
independent
• Only number 4) is insufficient to guarantee the independence
• Ex.: One of the event is Null
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 2116 June 2010
• Assume that the event of separate
experiments are independent
• Example:
• Assume that outcome of a coin toss is independent
of the outcomes of all prior and all subsequent coin
tosses
• P[H] = P[T] = ½
• P[HTH] = P[H] P[T] P[H] = 1/2*1/2*1/2 = 1/8
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 2216 June 2010
• Experiment: in sequence
subexperiments subexperiments
• Each subexp. may depend on the previous one
• Represented by a Tree Diagram
• Model Conditional Prob. Sequential Experiment
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 24
Leaf1
Outcome (node)
Outcomes of
the complete
Experiment (Leaf)
Branch
Prob. value
16 June 2010
• Timing coordination of 2 traffic lights
• P[the second light is the same color as the first] = 0.7
• Assume 1st light is equally likely to be green or red
• Find P[The second light is green] ?
• Find P[wait for at least one light] ?
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 2516 June 2010
26
• P[G1] = P[R1] = 0.5
0.5
0.5
0.7
0.3
0.3
0.7
G1
R1
G2
G2
R2
R2
G1G2 = 0.35
G1R2 = 0.15
R1G2 = 0.15
R1R2 = 0.35
• P[G2G1] = P[G2|G1]P[G1] = (0.7)(0.5) = 0.35
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
27
P[The second light is green] ?
P[G2] = P[G2G1] + P[G2R1] = 0.35 + 0.15 = 0.5
P[G2] = P[G2|G1]P[G1] + P[G2|R1]P[R1]
0.5
0.5
0.7
0.3
0.3
0.7
G1
R1
G2
G2
R2
R2
G1G2 = 0.35
G1R2 = 0.15
R1G2 = 0.15
R1R2 = 0.35
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
28
P[wait for at least one light] ?
W = {G1R2 R1G2 R1R2}
P[W] = P[G1R2] + P[R1G2] + P[R1R2]
= 0.15 + 0.15 + 0.35 = 0.65
0.5
0.5
0.7
0.3
0.3
0.7
G1
R1
G2
G2
R2
R2
G1G2 = 0.35
G1R2 = 0.15
R1G2 = 0.15
R1R2 = 0.35
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
16 June 2010 Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 29
0.4W1
L1
Korea Republic
Greece Argentina Nigeria
D1
W2
L2
D2
W2
L2
D2
W2
L2
D2
W3
L3
D3
W3
L3
D3
W3
L3
D3
0.1
0.5
0.3
0.1
0.6
0.6
0.1
0.3
0.6
0.1
0.30.6
0.1
0.3
0.3
0.1
0.6
0.3
0.1
0.6
W1W2W3 = 0.4 * 0.3 * 0.6 = 0.072
W1W2D3 = 0.4 * 0.3 * 0.1 = 0.012
W1W2L3 = 0.4 * 0.3 * 0.3 = 0.036
31
If experiment A has n possible outcomes,
and experiment B has k possible outcomes,
Then there are nk possible outcomes
when you perform both experiments
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
32
1st draw: select 1 out of 52 52 outcomes
2nddraw: select 1 out of 51 (one card has been drawn)
51 outcomes
3rddraw: select 1 out of 50 50 outcomes
Total outcomes = (52)(51)(50)
Example:
Shuffle a deck and select 3 cards in order.
How many outcomes?
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
16 June 2010 Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 33
(n-k)!(n-k)!
(n)k =n!
(n-k)!
n(n-1)(n-2)…(n-k+1) (n-k)(n-k-1)…(1)
(n-k)!=
(n)k = n(n-1)(n-2)…(n-k+1)
= n(n-1)(n-2)…(n-k+1)
Theorem:
The number of k-permutations, (n)k ,
(ordered sequence) of n distinguishable objects is
34
Example: You are allowed to choose only three from five items (in ordered sequence).
How many possible outcomes?
(n)k =n!
(n-k)!
(5)3 =5!
(5-3)!
5 x 4 x 3 x 2!
2!= = 60
A:
B:
C:
DifferentAnan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
35
Theorem: Given n distinguishable objects,
There are nk ways to choose with replacement
a sample of k objects
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
36
Example: You are allowed to choose only three from five items (with replacement).
How many possible outcomes?
nk = 5 x 5 x 5 = 125
A:
B:
C:
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
37
Theorem:
The number of ways to choose k objects
out of n distinguishable objects is
( )n
k=
(n)k
k!n!
k!(n-k)!=
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
38
2 subexperiments: ( ) then (k)k
( ). (k)k = (n)k
nknk
53( ) = 10
No order
(3)3 = 6
Order
1 2 3
(5)3 = 60
Order
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
39
• Perform repeated trials
• p = a success probability
• (1-p) = a failure probability
• Each trial is independent
• Sk,n = the event that k successes in n trials
( )n
kP[Sk,n] = pk(1-p)n-k
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
• 3 trials with 2 successes
• 000 001 010 011 100 101 110 111
• How many way to choose 2 out of 3
16 June 2010 Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 40
• What is the probability of success for each way ?• p2
* (1-p)
( )3
2P[S2,3] = p2(1-p)3-2
( )nk= = = 3( )3
2
• Example: In the first round of a programming contest,
probability that a program will pass the test is 0.8 .
• From 10 candidates, what is the probability that x candidates
will pass?
16 June 2010 Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 41
10
x( )P[Ax,10] = (0.8)x(1-0.8)10-x
P[A8,10] = (45)(0.1678)(0.04) = 0.3
Solution:
A = {program pass the test}, P[A] = 0.8
Testing a program is an independent trial
And what is P[x = 8]?
42
Let probability that a computer works = p
Series: P[A] = P[A1A2] = p2
Parallel: P[B] = ?
Series Parallel
Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty16 June 2010
P[B] = 1 – P[Bc]
= 1 – P[B1cB2
c]
= 1 – (1 – p)2
• Probability meaning
• Sample space, Event, Outcome
• Set Theory
• Probability measurement
• Conditional Probability
• Independence
• Sequential experiments tree diagram
• Counting Methods
• Independent Trials
16 June 2010 Anan Phonphoem, Dept.of Computer Engineering, Kasetsart Universty 43