PPT

Inclusion-Exclusion
Supplementary Notes
Prepared by Raymond Wong
Presented by Raymond Wong
1
e.g.1 (Page 3)
E
F
b
c





a
d
e
f
What is the size of E, denoted by S(E)?
What is the size of F, denoted by S(F)?
What is the size of E  F, denoted by S(E
3
4
 F)?
What is the size of E U F, denoted by S(E U F)?
1
6
Please express S(E U F) in terms of S(E), S(F)
and S(E
 F).
S(E U F) = S(E) + S(F) – S(E  F)
2
e.g.2 (Page 5)
E
F
b
c





a
d
e
f
We know that
S(E U F) = S(E) + S(F) – S(E  F)
where S(E) is the size of E
This principle also applies in probabilities
Let E and F be two events. We have
P(E U F) = P(E) + P(F) – P(E  F)
where P(E) is the probability of event E
3
E: sum is even
F: sum is 8 or more
e.g.3 (Page 6)







What
What
What
What
is
is
is
is
P(E)?
P(F)?
P(E  F)?
P(E U F)?
Consider we roll two dice.
Let E be the event that the sum of the two dice
is even
Let F be the event that the sum of the two dice
is 8 or more.
What
What
What
What
is
is
is
is
P(E)?
P(F)?
P(E  F)?
P(E U F)?
4
E: sum is even
F: sum is 8 or more
1/2
What
What
What
What
e.g.3
is
is
is
is
P(E)?
P(F)?
P(E  F)?
P(E U F)?
We want to find P(sum is even) = 1/2
Dice 1
Dice 2
1
1
1
Sum
Dice 1
Dice 2
2
3
1
2
3
3
1
3
4
1
4
1
Sum
Dice 1
Dice 2
Sum
4
5
1
6
2
5
5
2
7
3
3
6
5
3
8
5
3
4
7
5
4
9
5
6
3
5
8
5
5
10
1
6
7
3
6
9
5
6
11
2
1
3
4
1
5
6
1
7
2
2
4
4
2
6
6
2
8
2
3
5
4
3
7
6
3
9
2
4
6
4
4
8
6
4
10
2
5
7
4
5
9
6
5
11
2
6
8
4
6
10
6
6
12
5
E: sum is even
F: sum is 8 or more
1/2
15/36
What
What
What
What
e.g.3
is
is
is
is
P(E)?
P(F)?
P(E  F)?
P(E U F)?
We want to find P(sum is 8 or more) = 5/36 + 4/36 + 3/36 + 2/36 + 1/36 = 15/36
Dice 1
Dice 2
1
1
1
Sum
Dice 1
Dice 2
2
3
1
2
3
3
1
3
4
1
4
1
Sum
Dice 1
Dice 2
Sum
4
5
1
6
2
5
5
2
7
3
3
6
5
3
8
5
3
4
7
5
4
9
5
6
3
5
8
5
5
10
1
6
7
3
6
9
5
6
11
2
1
3
4
1
5
6
1
7
2
2
4
4
2
6
6
2
8
2
3
5
4
3
7
6
3
9
2
4
6
4
4
8
6
4
10
2
5
7
4
5
9
6
5
11
2
6
8
4
6
10
6
6
12
P(sum is 8) = 5/36
P(sum is 9) = 4/36
P(sum is 10) = 3/36
P(sum is 11) = 2/36
P(sum is 12) = 1/36
6
E: sum is even
F: sum is 8 or more
1/2
15/36
9/36
e.g.3
What
What
What
What
is
is
is
is
P(E)?
P(F)?
P(E  F)?
P(E U F)?
We want to find P(even sum is 8 or more) = 5/36 + 3/36 + 1/36 = 9/36
Dice 1
Dice 2
1
1
1
Sum
Dice 1
Dice 2
2
3
1
2
3
3
1
3
4
1
4
1
Sum
Dice 1
Dice 2
Sum
4
5
1
6
2
5
5
2
7
3
3
6
5
3
8
5
3
4
7
5
4
9
5
6
3
5
8
5
5
10
1
6
7
3
6
9
5
6
11
2
1
3
4
1
5
6
1
7
2
2
4
4
2
6
6
2
8
2
3
5
4
3
7
6
3
9
2
4
6
4
4
8
6
4
10
2
5
7
4
5
9
6
5
11
2
6
8
4
6
10
6
6
12
P(sum is 8) = 5/36
P(sum is 10) = 3/36
P(sum is 12) = 1/36
7
E: sum is even
F: sum is 8 or more
e.g.3
1/2
15/36
9/36
2/3
What
What
What
What
is
is
is
is
P(E)?
P(F)?
P(E  F)?
P(E U F)?
We want to find P(E U F)
P(E U F)
= P(E) + P(F) – P(E  F)
(By the Principle of Inclusion and Exclusion)
= 1/2 + 15/36 – 9/36
= 2/3
8
E
F
b
e.g.4 (Page 6)
d
e
a
c
h
g
f
i
j
G









5
What is the size of E, denoted by S(E)?
6
What is the size of F, denoted by S(F)?
5
What is the size of G, denoted by S(G)?
What is the size of E  F, denoted by S(E  F)?
What is the size of E  G, denoted by S(E  G)?
What is the size of F  G, denoted by S(F  G)?
What is the size of EFG, denoted by S(EFG)?
k
2
2
2
What is the size of E U F U G, denoted by S(E U F U G)?
Is “S(E U F U G) = S(E) + S(F) + S(G)
- S(E  F) – S(E  G) – S(F  G)”?
LHS = 11
RHS = 5 + 6 + 5 – 2 – 2 – 2 = 16 – 6 = 10
1
11
No
9
E
F
b
e.g.4
d
e
a
c
h
g
f
i
j
k
G









5
What is the size of E, denoted by S(E)?
6
What is the size of F, denoted by S(F)?
5
What is the size of G, denoted by S(G)?
What is the size of E  F, denoted by S(E  F)?
What is the size of E  G, denoted by S(E  G)?
What is the size of F  G, denoted by S(F  G)?
What is the size of EFG, denoted by S(EFG)?
2
2
2
1
What is the size of E U F U G, denoted by S(E U F U G)?
11
“S(E U F U G) = S(E) + S(F) + S(G)
- S(E  F) – S(E  G) – S(F  G) + S(EFG)”
LHS = 11
RHS = 5 + 6 + 5 – 2 – 2 – 2 + 1 = 16 – 6 + 1= 11
10
e.g.5 (Page 6)

We know that
S(E U F U G) = S(E) + S(F) + S(G)
- S(E  F) – S(E  G) – S(F  G)
+ S(EFG)



where S(E) is the size of E
This principle also applies in probabilities
Let E, F and G be three events. We have
P(E U F U G) = P(E) + P(F) + P(G)
- P(E  F) – P(E  G) – P(F  G)
+ P(EFG)

where P(E) is the probability of event E
11
e.g.6 (Page 10)

We have seen
P(E U F) = P(E) + P(F) – P(E  F)

We re-write as
P(E1 U E2) = P(E1) + P(E2) – P(E1  E2)

We further re-write as
 2  2
P  Ei    P( Ei )  P( E1  E2 )
 i 1  i 1
12
e.g.7 (Page 10)

We have seen
P(E U F U G) = P(E) + P(F) + P(G)
- P(E  F) – P(E  G) – P(F  G)
+ P(EFG)

We re-write as
P(E1 U E2 U E3) = P(E1) + P(E2) + P(E3)
- P(E1  E2) – P(E1  E3) – P(E2  E3)
+ P(E1E2E3)

We further re-write as
2
3
 3  3
P  Ei    P( Ei )    P( Ei  E j )  P( E1  E2  E3 )
i 1 j i 1
 i 1  i 1

We further re-write as
 3 
P  Ei  
 i 1 
 P( E
i1
i1:
1i1 3
)
 P( E
i1
i1 ,i2 :
1i1 i2 3
 Ei2 ) 
 P( E
i1
i1 ,i2 ,i3 :
1i1 i2 i3 3
 Ei2  Ei3 )
13
e.g.7

From
 3 
P  Ei  
 i 1 

 P( E
i1
i1:
1i1 3
)
 P( E
i1
 Ei2 ) 
i1 ,i2 :
1i1 i2 3
 P( E
i1
 Ei2  Ei3 )
i1 ,i2 ,i3 :
1i1 i2 i3 3
we further re-write as
 3

P  Ei 
 i 1 
 (1)11
 P( E
i1
i1 :
1i1 3
)  (1) 21
 P( E
i1
i1 ,i2 :
1i1 i2 3
 Ei2 )  (1) 31
 P( E
i1
 Ei2  Ei3 )
i1 ,i2 ,i3 :
1i1 i2 i3 3
14
e.g.7
 3

P  Ei 
 i 1 
 (1)11
 P( E
i1
i1 :
1i1 3
)  (1) 21
 P( E
i1
i1 ,i2 :
1i1 i2 3
 Ei2 )  (1) 31
 P( E
i1
 Ei2  Ei3 )
i1 ,i2 ,i3 :
1i1 i2 i3 3
15
e.g.7
 3

P  Ei 
 i 1 
 (1)11
 P( E
i1
i1 :
1i1 3

)  (1) 21
 P( E
i1
 Ei2 )  (1) 31
i1 ,i2 :
1i1 i2 3
 P( E
i1
 Ei2  Ei3 )
i1 ,i2 ,i3 :
1i1 i2 i3 3
we can re-write as
3
 3

P  Ei    (1) k 1
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik 3
16
e.g.7
3
 3

P  Ei    (1) k 1
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik 3
17
n
 n

P  Ei    (1) k 1
Prove that
 i 1  k 1
 P( E
 Ei2  ...  Eik )
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
e.g.8 (Page 13)

According to
3
 3

P  Ei    (1) k 1
 i 1  k 1

 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik 3
we deduce a general formula as follows
n
 n

P  Ei    (1) k 1
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
Why is it correct?
18
n
 n

P  Ei    (1) k 1
Prove that
 i 1  k 1


e.g.8

P
E
Let P(n) be      (1)
n
n
 i 1
i

k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
 P( E
k 1
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
Step 1: Prove that P(2) (i.e., the base case) is true.
We want to show that
2
 2

P  Ei    (1) k 1
 i 1  k 1
2
RHS of (*)   (1) k 1
k 1
 (1)11
 P( E
i1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  2
(*)
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  2
 P( E
2 1
)

(

1
)
i1
i1:
1i1  2
 P( E
i1
 Ei2 )
i1 ,i2 :
1i1 i2  2
21
 (1)11 ( P( E1 )  P( E2 ))  (1) P( E1  E2 )
 P( E1 )  P( E2 )  P( E1  E2 )
In some slides, we know that P(E1 U E2) = P(E1) + P(E2) – P(E1  E2)
Thus, P(2) is true.
19
n
 n

P  Ei    (1) k 1
Prove that
 i 1  k 1


e.g.8

P
E
Let P(n) be      (1)
n
 i 1
n
i

 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
k 1
 P( E
 Ei2  ...  Eik )
i1
k 1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
Step 2: Prove that “P(n-1) P(n)” is true for all n > 2.
Step 2(a): Assume that P(n-1) is true for n > 2.
 n 1  n 1
k 1


P
E

(

1
)
 i  
That is,
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
In other words, for any sets F1, F2, …, Fn-1, we have
 n 1  n 1
k 1

P
F

(

1
)
 i  
 i 1  k 1
 P( F
i1
 Fi2  ...  Fik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
20
n
 n

P  Ei    (1) k 1
Prove that
 i 1  k 1


e.g.8

P
E
Let
P(n) be      (1)
Objective:
n
 i 1
n
i

 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
k 1
k 1
 P( E
 Ei2  ...  Eik )
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
Step 2: Prove that “P(n-1) P(n)” is true for all n > 2.
Step 2(a): Assume that P(n-1) is true for n > 2.
In other words, for any sets F1, F2, …, Fn-1, we have
 n 1  n 1
k 1

P
F

(

1
)
 i  
 i 1  k 1
 P( F
i1
 Fi2  ...  Fik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
Step 2(b): According to P(n-1),
we deduce that P(n) is true.
We want to show that
n
 n

P  Ei    (1) k 1
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
21
n
 n

P  Ei    (1) k 1
Prove that
 i 1  k 1


e.g.8

P
E
Let
P(n) be      (1)
Objective:
n
 i 1
n
i

 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
k 1
k 1
 P( E
 Ei2  ...  Eik )
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
Step 2: Prove that “P(n-1) P(n)” is true for all n > 2.
Step 2(a): Assume that P(n-1) is true for n > 2.
In other words, for any sets F1, F2, …, Fn-1, we have
 n 1  n 1
k 1

P
F

(

1
)
 i  
 i 1  k 1
 P( F
i1
 Fi2  ...  Fik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
Step 2(b): According to P(n-1),
we deduce that P(n) is true.
 n

Consider P  Ei 
 i 1 
n 1


 P ( Ei )  En 
 i 1

n 1


 n 1

 P  Ei   PEn   P ( Ei )  En 
 i 1 
 i 1

P(E U F) = P(E) + P(F) – P(E  F)
(proved in the base case)
22


e.g.8

P
E
Let
P(n) be      (1)
Objective:
n
 i 1
n
i

k 1
k 1
 P( E
 Ei2  ...  Eik )
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
Inductive Hypothesis:
In other words, for any sets F1, F2, …, Fn-1, we have
 n 1  n 1
k 1

P
F

(

1
)
 i  
 i 1  k 1
 P( F
i1
 Fi2  ...  Fik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
 n

Consider P  Ei 
 i 1 
 n 1 
 n 1

 P  Ei   PEn   P ( Ei )  En 
 i 1 
 i 1

23
n
 n

k 1


P
E

(

1
)


i 
Let
P(n) be 
Objective:
 i 1  k 1
e.g.8
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
Inductive Hypothesis:
In other words, for any sets F1, F2, …, Fn-1, we have
 n 1  n 1
k 1

P
F

(

1
)


i


 i 1  k 1
 P( F
i1
 Fi2  ...  Fik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
 n

Consider P  Ei 
 i 1 
n 1


 n 1

 P  Ei   PEn   P ( Ei )  En 
 i 1 
 i 1

n 1


 P  Ei   PEn   P( E1  E2  ...  En 1 )  En 
 i 1 
 n 1 
 P  Ei   PEn   P( E1  En )  ( E2  En )  ...  ( En 1  En ) 
 i 1 




 P  Ei   PEn   P  ( Ei  En ) 
 i 1 
 i 1

n 1
n 1
(By Distributive Law)
Let Gi = Ei  En for i < n
 n 1 
 n 1 
 n

P  Ei   P  Ei   PEn   P  Gi 
 i 1 
 i 1 
 i 1 
24
n
 n

k 1


P
E

(

1
)


i 
Let
P(n) be 
Objective:
 i 1  k 1
e.g.8
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
Inductive Hypothesis:
In other words, for any sets F1, F2, …, Fn-1, we have
 n 1  n 1
k 1

P
F

(

1
)


i


 i 1  k 1
 n

Consider P  Ei 
 i 1 
 P( F
i1
 Fi2  ...  Fik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
Let Gi = Ei  En for i < n
 n 1 
 n 1 
 n

P  Ei   P  Ei   PEn   P  Gi 
 i 1 
 i 1 
 i 1 
25
n
 n

k 1


P
E

(

1
)


i 
Let
P(n) be 
Objective:
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
e.g.8
Inductive Hypothesis:
In other words, for any sets F1, F2, …, Fn-1, we have
 n 1  n 1
k 1

P
F

(

1
)


i


 i 1  k 1
 n

Consider P  Ei 
 i 1 
n 1


 n 1 
 P  Ei   PEn   P  Gi 
 i 1 
 i 1 
n 1
  (1) k 1
k 1
 P( E
i1
 P( F
i1
 Fi2  ...  Fik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
Let Gi = Ei  En for i < n
Gi1  Gi2  ...  Gik
 Ei1  Ei2  ...  Eik  En
 Ei2  ...  Eik )  PEn 
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
n 1
  (1) k 1
k 1
 P(G
i1
 Gi2  ...  Gik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
Consider Gi1  Gi2  ...  Gik
 ( Ei1  En )  ( Ei2  En )  ...  ( Eik  En )
 Ei1  En  Ei2  En  ...  Eik  En
 Ei1  Ei2  ...  Eik  En
26
n
 n

k 1


P
E

(

1
)


i 
Let
P(n) be 
Objective:
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
e.g.8
Inductive Hypothesis:
In other words, for any sets F1, F2, …, Fn-1, we have
 n 1  n 1
k 1

P
F

(

1
)


i


 i 1  k 1
 n

Consider P  Ei 
 i 1 
n 1


 n 1 
 P  Ei   PEn   P  Gi 
 i 1 
 i 1 
n 1
  (1) k 1
k 1
 P( E
i1
  (1) k 1
k 1
  (1) k 1
k 1
i1
 Fi2  ...  Fik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
Let Gi = Ei  En for i < n
Gi1  Gi2  ...  Gik
 Ei1  Ei2  ...  Eik  En
 Ei2  ...  Eik )  PEn 
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
n 1
n 1
 P( F
 P(G
i1
 Gi2  ...  Gik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
 P( E
i1
 Ei2  ...  Eik )  PEn 
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
n 1
  (1) k 1
k 1
 P( E
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
 Ei2  ...  Eik  En )
27
n
 n

k 1


P
E

(

1
)


i 
Let
P(n) be 
Objective:
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
e.g.8
 n

Consider P  Ei 
 i 1 
n 1
  (1) k 1
k 1
 P( E
i1
 Ei2  ...  Eik )  PEn 
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
n 1
  (1) k 1
k 1
 P( E
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
 Ei2  ...  Eik  En )
28
n
 n

k 1


P
E

(

1
)


i 
Let
P(n) be 
Objective:
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
 n

Consider P  Ei 
 i 1 
n 1
k 1
  (1)
 P( Ei1  Ei2  ...  Eik )  PEn 
e.g.8
k 1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
n 1
  (1) k 1
k 1
n 1
  (1) k 1
k 1
 P( E
i1
 Ei2  ...  Eik  En )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
 P( E
i1
 Ei2  ...  Eik )  PEn 
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
n 1
  (1) k  2
k 1
 P( E
i1
 Ei2  ...  Eik  En )
…………(**)
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
n 1
Consider P( En )   (1) k  2
k 1
 P( E
i1
 Ei2  ...  Eik  En )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
29
e.g.8
n 1
Consider P( En )   (1) k  2
k 1
 P( E
i1
 Ei2  ...  Eik  En )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
30
n 1
Consider P( En )   (1) k  2
k 1
 P( E
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
n 1
e.g.8
 P( En )   (1) k  2
k 1
 P( E
i1
 P( En )   (1) a 1
11
 (1)
n
 P( E
i1
k 2
  (1) k 1
k 1
n 1
  (1) k 1
k 1
i1
 P( E
i1
 Ei2  ...  Eik 1  Eik )
 Ei2  ...  Eik 1  Eik )
i1 ,i2 ,..., ik 1 ,ik :
1i1 i2 ... ik 1 ik  n
and ik  n
 P( E
i1
P( En )   (1)
k 1
  (1) k 1
k 1
(where k+1 = a)
i1 ,i2 ,..., ik 1 ,ik :
1i1 i2 ... ik 1 ik  n
and ik  n
 P( E
i1 ,i2 ,..., ik 1 ,ik :
1i1 i2 ... ik 1 ik  n
and ik  n
n 1
k 2
n 1
 Ei2  ...  Eia1  Eia )
i1 ,i2 ,..., ia 1 ,ia :
1i1 i2 ... ia 1 ia  n
and ia  n
P( En )   (1) k 1
n
 Ei2  ...  Eik  Eik 1 )
i1 ,i2 ,..., ik ,ik 1:
1i1 i2 ... ik ik 1  n
and ik 1  n
n
a 2
 Ei2  ...  Eik  En )
 Ei2  ...  Eik 1  Eik )  (1) n 1 P( E1  E2  ...  En )
 P( E
i1
 Ei2  ...  Eik  En )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
 P( E
i1
i1 ,i2 ,..., ik 1 ,ik :
1i1 i2 ... ik 1 ik  n
and ik  n
 Ei2  ...  Eik )  (1) n 1 P( E1  E2  ...  En )
31
e.g.8
n 1
P( En )   (1) k  2
n 1
k 1
  (1) k 1
k 1
 P( E
i1
 Ei2  ...  Eik  En )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
 P( E
i1
i1 ,i2 ,..., ik 1 ,ik :
1i1 i2 ... ik 1 ik  n
and ik  n
 Ei2  ...  Eik )  (1) n 1 P( E1  E2  ...  En )
32
n
 n

k 1


P
E

(

1
)


i 
Let
P(n) be 
Objective:
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
From (**), we have
e.g.8
 n

P  Ei 
 i 1 
n 1
  (1) k 1
k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
n 1
k 2
 P( En )   (1)
k 1
n 1
  (1) k 1
k 1
n 1
 Ei2  ...  Eik  En )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
k 1
 P( E
i1
 Ei2  ...  Eik )  (1) n 1 P( E1  E2  ...  En )
i1 ,i2 ,..., ik 1 ,ik :
1i1 i2 ... ik 1 ik  n
and ik  n
n 1
P( En )   (1) k  2
k 1
  (1) k 1
k 1
i1
 P( E
  (1) k 1
n 1
 P( E
 P( E
i1
 Ei2  ...  Eik  En )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
 P( E
i1
i1 ,i2 ,..., ik 1 ,ik :
1i1 i2 ... ik 1 ik  n
and ik  n
 Ei2  ...  Eik )  (1) n 1 P( E1  E2  ...  En )
33
n
 n

k 1


P
E

(

1
)


i 
Let
P(n) be 
Objective:
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
From (**), we have
e.g.8
 n

P  Ei 
 i 1 
n 1
  (1) k 1
k 1
n 1
 P( E
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
  (1) k 1
k 1
 Ei2  ...  Eik )
 P( E
i1
 Ei2  ...  Eik )  (1) n 1 P( E1  E2  ...  En )
i1 ,i2 ,..., ik 1 ,ik :
1i1 i2 ... ik 1 ik  n
and ik  n
34
n
 n

k 1


P
E

(

1
)


i 
Let
P(n) be 
Objective:
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
From (**), we have
e.g.8
 n

P  Ei 
 i 1 
n 1
  (1) k 1
k 1
n 1
 P( E
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n 1
  (1) k 1
k 1
  (1) k 1
k 1
 P( E
i1
  (1)
k 1
  (1) k 1
k 1
 Ei2  ...  Eik )  (1) n 1 P( E1  E2  ...  En )
 Ei2  ...  Eik )
 P( E
i1
 Ei2  ...  Eik )  (1) n 1 P( E1  E2  ...  En )
i1 ,i2 ,..., ik 1 ,ik :
1i1 i2 ... ik 1 ik  n
and ik  n
  (1) k 1
n
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
and ik  n
k 1
n 1
k 1
 P( E
i1 ,i2 ,..., ik 1 ,ik :
1i1 i2 ... ik 1 ik  n
and ik  n
n 1
n 1
 Ei2  ...  Eik )
 P( E
i1
 Ei2  ...  Eik )  (1) n 1 P( E1  E2  ...  En )
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
 P( E
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
Thus, P(n) is true.
35
n
 n

k 1


P
E

(

1
)


i 
Let
P(n) be 
Objective:
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
e.g.8
We prove that “P(n-1) P(n)” is true
for all n > 2
By Mathematical Induction,
n  2,
n
n


P  Ei    (1) k 1
 i 1  k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
36
e.g.9 (Page 22)


n
 n

P  Ei    (1) k 1
 i 1  k 1
We know that
What is P(E1 U E2 U E3 U E4)?
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
P(E1 U E2 U E3 U E4) = P(E1) + P(E2) + P(E3) + P(E4)
- P(E1  E2) - P(E1  E3) - P(E1  E4)
- P(E2  E3) - P(E2  E4) - P(E3  E4)
+ P(E1  E2  E3) + P(E1  E2  E4)
+ P(E1  E3  E4) + P(E2  E3  E4)
- P(E1  E2  E3  E4)
37
(a) What is the probability that Raymond gets his OWN backpack back?
(b) What is the probability that Raymond and Peter get their OWN backpacks back?
e.g.10 (Page 23)






There are 5 students who have the same model and
color of backpack.
They put their backpacks randomly along the wall.
Someone mixed up the backpacks so students get back
“random” backpacks.
Suppose that there are two students called “Raymond”
and “Peter”
(a) What is the probability that Raymond gets his OWN
backpack back?
(b) What is the probability that Raymond and Peter get
their OWN backpacks back?
38
(a) What is the probability that Raymond gets his OWN backpack back?
(b) What is the probability that Raymond and Peter get their OWN backpacks back?
e.g.10
(a)
Raymond
Peter
There are (5-1)! cases that Raymond gets his OWN backpack back.
There are totally 5! cases
P(Raymond gets his OWN backpack back) =
(5-1)!
5!
39
(a) What is the probability that Raymond gets his OWN backpack back?
(b) What is the probability that Raymond and Peter get their OWN backpacks back?
e.g.10
(b)
Raymond
Peter
There are (5-2)! cases that Raymond and Peter get their OWN backpacks back.
There are totally 5! cases
P(Raymond and Peter get their OWN backpacks back) =
(5-2)!
5!
40
(a) What is the probability 1 specified student gets his OWN backpack back?
(b) What is the probability k specified students get their OWN backpacks back?
e.g.11 (Page 23)






There are n students who have the same model and
color of backpack.
They put their backpacks randomly along the wall.
Someone mixed up the backpacks so students get back
“random” backpacks.
Suppose that there are two students called “Raymond”
and “Peter”
(a) What is the probability 1 specified student gets his
OWN backpack back?
(b) What is the probability k specified students get their
OWN backpacks back?
41
1
(a) What is the probability 1 specified student gets his OWN backpack back?
(b) What is the probability k specified students get their OWN backpacks back?
n
e.g.11
(a)
…
Raymond
Peter
n
There are (n-1)! cases that 1 specified student gets his OWN backpack back.
There are totally n! cases
P(1 specified student gets his OWN backpack back) =
(n-1)!
n!
=
(n-1)!
(n-1)!.n
=
1
n
42
(a) What is the probability 1 specified student gets his OWN backpack back?
1
n
(b) What is the probability k specified students get their OWN backpacks back? (n-k)!
e.g.11
n!
k
(b)
…
…
Raymond
Peter
n
There are (n-k)! cases that k specified students get their OWN backpacks back.
There are totally n! cases
P(k specified students their OWN backpacks back) =
(n-k)!
n!
43
(a) What is the probability 1 specified student gets his OWN backpack back?
1
n
(b) What is the probability k specified students get their OWN backpacks back? (n-k)!
e.g.12 (Page 26)



n!
Suppose that there are 5 students (i.e., n = 5)
Let Ei be the event that student i gets his own
backpack back.
What is the probability that at least one person
gets his own backpack?
P(at least one person gets his own backpack)
= P(E1 U E2 U E3 U E4 U E5)
5
  (1) k 1
k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik 5
44
(a) What is the probability 1 specified student gets his OWN backpack back?
1
n
(b) What is the probability k specified students get their OWN backpacks back? (n-k)!
e.g.12
Let Ei be the event that student i gets his own backpack back.
n!
P(at least one person gets his own backpack)
= P(E1 U E2 U E3 U E4 U E5)
5
  (1) k 1
k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik 5
P(k specified students get their own backpacks back)
5
  (1) k 1
k 1

i1 ,i2 ,..., ik :
1i1 i2 ... ik 5
(5  k )!
5!
How many possible tuples in form of (i1, i2, …, ik) where
1  i1 < i2 < … < ik  5?
5
k
 5  (5  k )!
  (1)  
k 1
 k  5!
5
5
5!
(5  k )!
1
k 1
  (1)

  (1) k 1
k!(5  k )!
5!
k!
k 1
k 1
5
k 1
45
(a) What is the probability 1 specified student gets his OWN backpack back?
1
n
(b) What is the probability k specified students get their OWN backpacks back? (n-k)!
e.g.12
Let Ei be the event that student i gets his own backpack back.
n!
P(at least one person gets his own backpack)
5
  (1) k 1
k 1
1
k!
46
(a) What is the probability 1 specified student gets his OWN backpack back?
1
n
(b) What is the probability k specified students get their OWN backpacks back? (n-k)!
e.g.12
Let Ei be the event that student i gets his own backpack back.
n!
P(at least one person gets his own backpack)
5
  (1)
k 1
k 1
1
k!
1
1
1
1
1
 (1)11  (1) 21  (1)31  (1) 41  (1)51
1!
2!
3!
4!
5!
1 1 1 1
 1   
2! 3! 4! 5!
P(at least one person gets his own backpack)  1 
1 1 1 1
  
2! 3! 4! 5!
47
(a) What is the probability 1 specified student gets his OWN backpack back?
1
n
(b) What is the probability k specified students get their OWN backpacks back? (n-k)!
e.g.13 (Page 28)



n!
Suppose that there are 5 students (i.e., n = 5)
Let Ei be the event that student i gets his own
backpack back.
What is the probability that nobody gets his own
backpack?
P(nobody gets his own backpack)
= 1 – P(at least one person gets his own backpack)
1
1
1
1
 1  (1 



)
2
!
3
!
4
!
5
!
1
1
1
1




2!
3!
4!
5!
P(at least one person gets his own backpack)  1 
1 1 1 1
  
2! 3! 4! 5!
48
(a) What is the probability 1 specified student gets his OWN backpack back?
1
n
(b) What is the probability k specified students get their OWN backpacks back? (n-k)!
e.g.14 (Page 29)



n!
Suppose that there are n students
Let Ei be the event that student i gets his own
backpack back.
What is the probability that at least one person
gets his own backpack?
P(at least one person gets his own backpack)
= P(E1 U E2 U … U En)
n
  (1) k 1
k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
49
(a) What is the probability 1 specified student gets his OWN backpack back?
1
n
(b) What is the probability k specified students get their OWN backpacks back? (n-k)!
e.g.14
Let Ei be the event that student i gets his own backpack back.
n!
P(at least one person gets his own backpack)
= P(E1 U E2 U … U En)
n
  (1) k 1
k 1
 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
P(k specified students get their own backpacks back)
n
  (1) k 1
k 1

i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
(n  k )!
n!
How many possible tuples in form of (i1, i2, …, ik) where
1  i1 < i2 < … < ik  n?
n
k
 n  (n  k )!
  (1)  
k 1
 k  n!
n
n
n!
(n  k )!
1
k 1
  (1)

  (1) k 1
k!(n  k )!
n!
k!
k 1
k 1
n
k 1
50
(a) What is the probability 1 specified student gets his OWN backpack back?
1
n
(b) What is the probability k specified students get their OWN backpacks back? (n-k)!
e.g.12
Let Ei be the event that student i gets his own backpack back.
n!
P(at least one person gets his own backpack)
n
  (1) k 1
k 1
1
k!
51
(a) What is the probability 1 specified student gets his OWN backpack back?
1
n
(b) What is the probability k specified students get their OWN backpacks back? (n-k)!
e.g.12
Let Ei be the event that student i gets his own backpack back.
n!
P(at least one person gets his own backpack)
n
  (1)
k 1
k 1
1
k!
P(at least one person gets his own backpack) 
n
 (1)
k 1
k 1
1
k!
52
(a) What is the probability 1 specified student gets his OWN backpack back?
1
n
(b) What is the probability k specified students get their OWN backpacks back? (n-k)!
e.g.15 (Page 29)



n!
Suppose that there are n students
Let Ei be the event that student i gets his own
backpack back.
What is the probability that nobody gets his own
Dearrangement Problem
backpack?
P(nobody gets his own backpack)
= 1 – P(at least one person gets his own backpack)
n
 1  ( (1) k 1
k 1
1
)
k!
P(at least one person gets his own backpack) 
n
 (1)
k 1
k 1
1
k!
53
e.g.15
P(nobody gets his own backpack)
= 1 – P(at least one person gets his own backpack)
n
1
 1  ( (1)
)
k!
k 1
1
1
1
1
 1  (( 1)11   (1) 21   (1) 31   ...  (1) n 1  )
1!
2!
3!
n!
1 1 1
1
 1  (    ...  (1) n 1  )
1! 2! 3!
n!
1 1 1
1
 1     ...  (1) n  2 
1! 2! 3!
n!
1 1 1
1
 1     ...  (1) n 
1! 2! 3!
n!
Note that from calculus, we have
(1) 2 (1)3
(1) n
 1  (1) 

 ... 

x 2 x3
xi
2!
3!
n!
x
e  1  x    ...  
2! 3!
i 0 n!
 e 1 if n is a large number
k 1
54
e.g.15
P(nobody gets his own backpack)
(1) 2 (1)3
(1) n
 1  (1) 

 ... 
2!
3!
n!
 e 1
if n is a large number
55
e.g.15
(1) (1)
 1  (1) 

P(nobody gets his own backpack)
2
2!
e
n
1
(1) n
 ... 
3!
n!
3
if n is a large number
(1) 2 (1)3
(1) n
1  (1) 

 ... 
2!
3!
n!
e-1 = 0.367879441
56
e.g.16 (Page 33)

Principle of Inclusion and Exclusion for Probability
 n  n
P  Ei    (1) k 1
 i 1  k 1

 P( E
i1
 Ei2  ...  Eik )
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
Principle of Inclusion and Exclusion for Counting
n
n
k 1
E

(

1
)
 i 
i 1
k 1
E
i1
 Ei2  ...  Eik
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
57
e.g.17 (Page 33)

How many functions from a 6-element set
N to a 5-element set M = {y1, y2, …, y5}
are there? N
5 choices
1
5 choices
2
5 choices
5 choices
3
4
5 choices
5
5 choices
6
M
y1
y2
y3
y4
y5
Total no. of functions = 5 x 5 x 5 x 5 x 5 x 5= 56
58
e.g.18 (Page 33)

How many functions from a 6-element set
N to a 5-element set M = {y1, y2, …, y5}
map nothing to y1?
N
4 choices
1
4 choices
2
4 choices
4 choices
3
4
4 choices
5
4 choices
6
M
y1
y2
y3
y4
y5
Total no. of functions = 4 x 4 x 4 x 4 x 4 x 4= 46
59
e.g.19 (Page 33)

How many functions from a 6-element set
N to a 5-element set M = {y1, y2, …, y5}
map nothing to y1 and y2?
N
3 choices
1
3 choices
2
3 choices
3 choices
3
4
3 choices
5
3 choices
6
M
y1
y2
y3
y4
y5
Total no. of functions = 3 x 3 x 3 x 3 x 3 x 3= 36
60
Total no. of functions that map nothing to a given set K of k elements in M= (5-k)6
e.g.20 (Page 33)

How many functions from a 6-element set N
to a 5-element set M = {y1, y2, …, y5} map
nothing to a given set K of k elements in M
(e.g., {y1, y2})?
N
(5-k) choices
(5-k) choices
1
(5-k) choices
3
4
(5-k) choices
2
(5-k) choices 5
(5-k) choices 6
M
y1
y2
y3
y4
y5
Total no. of functions = (5-k) x (5-k) x (5-k) x (5-k) x (5-k) x (5-k) = (5-k)6
61
Total no. of functions that map nothing to a given set K of k elements in M= (5-k)6
Principle of Inclusion-and-Exclusion
e.g.21 (Page 34)
n
n
 E   (1)
i
i 1
E
k 1
k 1
i1
 Ei2  ...  Eik
i1 ,i2 ,..., ik :
1i1 i2 ... ik  n
How many functions from a 6-element set N
to a 5-element set M = {y1, y2, …, y5} map
nothing to at least one element in M?

Let Ei be a set of functions which map nothing to element yi
Total no. of functions that map nothing to at least one element in M
= E1 U E2 U … U E5
=
N
1
5
E
i
2
i 1
5
  (1) k 1
k 1
E
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik 5
 Ei2  ...  Eik
3
4
5
6
M
y1
y2
y3
y4
y5
62
Total no. of functions that map nothing to a given set K of k elements in M= (5-k)6
e.g.21
How many functions from a 6-element set N
to a 5-element set M = {y1, y2, …, y5} map
nothing to at least one element in M?

Let Ei be a set of functions which map nothing to element yi
Total no. of functions that map nothing to at least one element in M
N
1
5
  (1) k 1
k 1
E
i1
i1 ,i2 ,..., ik :
1i1 i2 ... ik 5
2
 Ei2  ...  Eik
3
4
5
6
M
y1
y2
y3
y4
y5
63
Total no. of functions that map nothing to a given set K of k elements in M= (5-k)6
5
Total no. of functions that map nothing to at least one element in M=  (1) k 1  5 (5  k ) 6
k 
k 1
 
e.g.21
Let Ei be a set of functions which map nothing to element yi
How many functions from a 6-element set N
to a 5-element
set
M
=
{y
,
,
…,
y
}
map
Total
no.
ofyfunctions
that
map
1
2
5
  (1)
E

E

...

E

nothing to a given set K of
nothing to at least one
element in M?
k elements where K = {y , y , …, y }

Total no. of functions that map nothing to at least one element in M
5
k 1
k 1
5
  (1) k 1
k 1
i1
i2
i1 ,i2 ,..., ik :
1i1 i2 ... ik 5
 (5  k )
i1
6
i1 ,i2 ,..., ik :
1i1 i2 ... ik 5


k 1  5 
6
  (1)  (5  k ) 
k 1
 k 

5
k 1  5 
  (1)  (5  k ) 6
k 1
k 
5
ik
i2
ik
How many possible tuples in form of (i1, i2, …, ik) where
1  i1 < i2 < … < ik  5?
5
k
N
1
2
3
4
5
6
M
y1
y2
y3
y4
y5
64
Total no. of functions that map nothing to at least one element in M=
 (1)
k 1
k 1
e.g.22 (Page 37)

5
5
 (5  k ) 6
k 
How many onto functions from a 6-element set N
to a 5-element set M = {y1, y2, …, y5} are there?
N
1
2
3
4
5
6
M
y1
y2
y3
y4
y5
65
Total no. of functions that map nothing to at least one element in M=
 (1)
k 1
e.g.22

5
k 1
5
 (5  k ) 6
k 
Onto function (or surjection)
N
N
M
M
66
Total no. of functions that map nothing to at least one element in M=
 (1)
k 1
e.g.22

5
k 1
5
 (5  k ) 6
k 
Not onto function (or not surjection)
N
M
NS
M
67
From “e.g.,17”, Total no. of functions from a 6-element set N to a 5-element set M = 56
5
Total no. of functions that map nothing to at least one element in M=  (1) k 1  5 (5  k ) 6
k 
k 1
 
e.g.22

How many onto functions from a 6-element set N
to a 5-element set M = {y1, y2, …, y5} are there?
Total no. of onto functions from a 6-element set N to a 5-element set M
= Total no. of functions from a 6-element set N to a 5-element set M
- Total no. of functions that are NOT onto
= Total no. of functions from a 6-element set N to a 5-element set M
- Total no. of functions that map nothing to at least one element in M
5
N
k 1  5 
6
M
6


(

1
)
(
5

k
)
=5 -
k 
1
k 1
 
y1
5
5

k

2
6
= 56 +  (1)  (5  k )
2
y2
k
k 1
 
5
y3
3
k 5
5
0
6
 (5  k ) 6
(

1
)
= (-1)
(5-0) + 
0
k 1
k 
4
y4
5
k 5
5
 (5  k ) 6
(

1
)
y5
=
k
k 0
 
6
68
e.g.22

How many onto functions from a 6-element set N
to a 5-element set M = {y1, y2, …, y5} are there?
Total no. of onto functions from a 6-element set N to a 5-element set M
N
1
2
k 5
 (5  k ) 6
(

1
)
=
k 0
k 
5
3
4
5
6
M
y1
y2
y3
y4
y5
69
e.g.22

How many onto functions from a 6-element set N
to a 5-element set M = {y1, y2, …, y5} are there?
Total no. of onto functions from a 6-element set N to a 5-element set M
=
5
6


(

1
)
(
5

k
)

k 
k 0
 
5
k
N
1
2
3
4
5
6
M
y1
y2
y3
y4
y5
70
e.g.23 (Page 37)

n
How many onto functions from a 6-element
set N
to a m5-element set M = {y1, y2, …, y5m} are there?
Total no. of onto functions from a 6-element
set N to a 5-element
set M
n
m
=
 5m 
6n
(1)  (5m  k )

k 0
k 
m
5
k
N
1
2
3
4
…
5
n6
M
y1
y2
y3
y…
4
yy5
m
71