0% found this document useful (0 votes)
37 views4 pages

Mathematical Foundations of Computer Science Lecture Outline

The document provides an outline for a lecture on mathematical foundations of computer science. It covers topics such as binomial distributions, the coupon collector's problem, binary relations, and properties of relations. It defines key concepts such as binomial random variables, expectation and variance of binomial distributions, relations on sets, and properties like reflexive, symmetric, and transitive for relations. Examples are given to illustrate the different topics.

Uploaded by

Chenyang Fang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views4 pages

Mathematical Foundations of Computer Science Lecture Outline

The document provides an outline for a lecture on mathematical foundations of computer science. It covers topics such as binomial distributions, the coupon collector's problem, binary relations, and properties of relations. It defines key concepts such as binomial random variables, expectation and variance of binomial distributions, relations on sets, and properties like reflexive, symmetric, and transitive for relations. Examples are given to illustrate the different topics.

Uploaded by

Chenyang Fang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Mathematical Foundations of Computer Science

Lecture Outline
November 20, 2018

Binomial Distributions
Consider an experiment in which we perform a sequence of n coin flips in which the prob-
ability of obtaining heads is p. How many flips result in heads?

If X denotes the number of heads that appear then


 
n j
Pr[X = j] = p (1 − p)n−j
j
Definition. A binomial random variable X with parameters n and p is defined by the
following probability distribution on j = 0, 1, 2, . . . , n:
 
n j
Pr[X = j] = p (1 − p)n−j
j
We can verify that the above is a valid probability distribution using the binomial theorem
as follows
n  
X n j
p (1 − p)n−j = (p + (1 − p))n = 1
j
j=1
What is the expectation of a binomial random variable X? We can calculate E[X] is two
ways. We first calculate it directly from the definition.
n  
X n j
E[X] = j p (1 − p)n−j
j
j=0
n
X n!
= j pj (1 − p)n−j
j!(n − j)!
j=0
n
X n!
= j pj (1 − p)n−j
j!(n − j)!
j=1
n
X n!
= pj (1 − p)n−j
(j − 1)!(n − j)!
j=1
n
X (n − 1)!
= np pj−1 (1 − p)(n−1)−(j−1)
(j − 1)!((n − 1) − (j − 1))!
j=1
n−1
X (n − 1)!
= np pk (1 − p)(n−1)−k
k!((n − 1) − k)!
k=0
n−1
X  n − 1
= np pk (1 − p)(n−1)−k
k
k=0
= np
2 Lecture Outline November 20, 2018

The last equation follows from the binomial expansion of (p + (1 − p))n−1 .

We can obtain the result in a much simpler way by using the linearity of expectation. Let
Xi , 1 ≤ i ≤ n be the indicatorP
random variable that is 1 if the ith flip results in heads and
is 0 otherwise. We have X = ni=1 Xi . By the lineartity of expectation we have
n
X n
X
E[X] = E[Xi ] = p = np
i=1 i=1
Pn
What is the variance of the binomial random variable X? Since X = i=1 Xi , and
X1 , X2 , . . . , Xn are independent we have
n
X
Var[X] = Var[Xi ]
i=1
Xn
= E[Xi2 ] − E[Xi ]2
i=1
n
X
= (p − p2 )
i=1
= np(1 − p)

Coupon Collector’s Problem.


We are trying to collect n different coupons that can be obtained by buying cereal boxes.
The objective is to collect at least one coupon of each of the n types. Assume that each
cereal box contains exactly one coupon and any of the n coupons is equally likely to occur.
How many cereal boxes do we expect to buy to collect at least one coupon of each type?

Solution. Let the random variable X denote the number of cereal boxes bought until we
have at least one coupon of each type. We want to compute E[X]. Let Xi be the random
variable denoting the number of boxes bought to get the ith new coupon. Clearly,

X = X1 + X2 + X3 + . . . + Xn

Using the linearity of expectation we have

E[X] = E[X1 ] + E[X2 ] + E[X3 ] + . . . + E[Xn ] (1)

What is the distribution of random variable Xi ? Observe that the probability of obtaining
the ith new coupon is given by
n − (i − 1) n−i+1
pi = =
n n
Thus the random variable Xi , 1 ≤ i ≤ n is a geometric random variable with parameter pi .
1 n
E[Xi ] = =
pi n−i+1
November 20, 2018 Lecture Outline 3

Combining this with equation (1) we get


n
n n n n n X1
E[X] = + + + ··· + + = n
n n−1 n−2 2 1 i
i=1
Pn 1
The summation i−1 i is known as the harmonic number H(n) and H(n) = ln n + c, for
some constant c < 1.

Hence the expected number of boxes needed to collect n coupons is about nH(n) < n(ln n+
1).

Relations
A binary relation is a set of ordered pairs. For example, let R = {(1, 2), (2, 3), (5, 4)}. Then
since (1, 2) ∈ R, we say that 1 is related to 2 by relation R. We denote this by 1 R 2.
Similarly, since (4, 7) 6∈ R, 4 is not related to 7 by relation R, denoted by 4 6R 7.
A binary relation R from set A to set B is a subset of the cartesian product A × B.
When A = B, we say that R is a relation on set A.

Example. Let A = {1, 2, 3, 4} and B = {a, b, c}. Consider the following relations.

R1 = {(1, 1), (1, 2), (2, 2), (2, 3)}


R2 = {(1, 2), (2, 3), (3, 4), (4, 1), (4, 4)}
R3 = {(1, a), (2, a), (3, b), (4, c)}
R4 = {(a, 1), (a, 3), (a, 4), (c, 1)}
R5 = {(a, a), (a, b), (1, c)}

R1 and R2 are relations on A. R3 is a relation from A to B. R4 is a relation from B to A.


R5 is not a relation on sets A and B and it is neither a relation from A to B nor a relation
from B to A.
Below are some more examples of relations.

• If S is a set then “is a subset of “, ⊆ is a relation on P(S), the power set of S.

• “is a student in” is a relation from the set of students to the set of courses.

• “=” is a relation on Z.

• “has a path in G to” is a relation on V (G), the set of vertices in G.

Example. How many relations are there on a set of n elements?

Solution. Note that |A × A| = n2 . Since any relation on A is a subset of A × A, the


2
number of possible relations is the cardinality of the power set of A × A, which is 2n .
4 Lecture Outline November 20, 2018

Properties of Relations
Let R be a relation defined on set A. We say that R is

• reflexive, if for all x ∈ A, (x, x) ∈ R.

• irreflexive, if for all x ∈ A, (x, x) 6∈ R.

• symmetric, if for all x, y ∈ A, (x, y) ∈ R =⇒ (y, x) ∈ R.

• antisymmetric, if for all x, y ∈ A, x R y and y R x =⇒ x = y.

• transitive, if for all x, y, z ∈ A, x R y and y R z =⇒ x R z.

Note that the terms symmetric and antisymmetric are not opposites. A relation may be
both symmetric and antisymmetric or can neither be symmetric nor be antisymmetric.

You might also like