HW8 - Lê Trần Đăng Khoa - 2352564

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

VIET NAM NATIONAL UNIVERSITY HO CHI

MINH CITY
HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY
Faculty of Computer Science and Engineering

May 3, 2024

HOMEWORK REPORT
Course: Discrete Structures for
Computing CCO1 - Group 5
HW8: Discrete Probability

Lecturer in charge: Prof. NGUYEN AN KHUONG

Student’s name Student’s ID

LE TRAN DANG KHOA 2352564

1
7.1
33.
a) 1 / (200.199.198) / 7,880,400
b) 1 / (200.200.200) / 8,000,000

34.
a) 1/(50 . 49 . 48 . 47) = 1 / 5527200.
b) 1/504 = 1/6250000.

35.
a) 9 / 19
b) 81 / 361
c) 1 / 19
d) 1,889,568 / 2,476,099
e) 48 / 361

36.
We see that there are 5 ways to get a total of 8 when two dice are rolled: (6, 2), (5, 3), (4, 4), (3,
5), and (2, 6). There are 62 = 36 equally likely possible outcomes of the roll of two dice, so the
probability of getting a total of 8 when two dice are rolled is 5/36 ≈ 0.139. For three dice, there
are 63 = 216 equally likely possible outcomes, which we can represent as ordered triples (a, b, c).
We need to enumerate the possibilities that give a total of 8. The first die could turn out to be a 6,
giving rise to the 1 triple (6, 1, 1). The first die could be a 5, giving rise to the 2 triples (5, 2, 1),
and (5, 1, 2). Continuing in this way, we see that there are 3 triples giving a total of 8 when the first
die shows a 4, 4 triples when it shows a 3, 5 triples when it shows a 2, and 6 triples when it shows
a 1 (namely (1, 6, 1), (1, 5, 2), (1, 4, 3), (1, 3, 4), (1, 2, 5), and (1, 1, 6) ). Therefore there are 1 +
2 + 3 + 4 + 5 + 6 = 21 possible outcomes giving a total of 8. This tells us that the probability of
rolling a 8 when three dice are thrown is 21 / 216 ≈ 0.097, smaller than the corresponding value
for two dice. Thus rolling a total of 8 is more likely when using two dice than when using three.

37.
Rolling a total of 9 when three dice are rolled is more likely.

38.
There are C(70,5).25 = 302,575,350 ways to choose five of the numbers between 1 and 70 and a
sixth number between 1 and 25, so this is the size of the sample space.
a) There is only one way to win the jackpot, so the probability is 1 / 302,575,350 ≈ 3.3 × 10−9 .
b) There are 24 ways to match the first five numbers but not the sixth, so the probability is 24 /
302,575,350 = 4 / 50,429,225 ≈ 7.9 × 10−8 .
c) To count the number of ways to match four of the first five numbers, we first select four of the

2
numbers to match, then we pick one of the 65 non-winning numbers and then one of the 24 non-
winning sixth numbers, giving C(5, 4) . 65 . 24 = 7800, and the probability is 7800 / 302,575,350
= 52 / 2,017,169 ≈ 0.000026.
d) The number of ways to match three of the first five numbers but not match the sixth is C(5, 3)
. C(65, 2) . 24 = 499,200 and the number of ways to match two of the first five and the sixth is
C(5, 2) . C(65, 3) . 1 = 436,800. These are disjoint, so the probability of winning $10 is 936,000 /
302,575,350 = 6240 / 2,017,169 ≈ 0.0031.

39.
a) 4 / 756,438,375
b) 13 / 30,257,535
c) 4888 / 2,750,685
d) 90,272 / 9,823,875

40.
The size of the sample space is C(69, 5) . 26 = 292,201,338. a) There is only one way to win the
jackpot, so the probability is 1 / 292,201,338 ≈ 3.4 × 10−9 .
b) To match the first five numbers but not the sixth, the sixth number must be one of the other 25
possibilities and the probability is 25 / 292,201,338 ≈ 8.6 × 10−8 .
c) There are C(5, 3) . C(64, 2) = 20,160 ways to match three of the first five numbers and the
sixth. There are C(5, 4) . 64 . 25 = 8000 ways to match four of the first five numbers but not the
sixth. So the probability is 28,160 / 292,201,338 = 1280 / 13,281,879 ≈ 0.000096.
d) There are C(5, 1) . C(64, 4) . 1 = 3,176,880 ways to match one of the first five numbers and the
sixth and C(5, 0) . C(64, 5) . 1 = 7,624,512 ways to match none of the first five numbers and the
sixth. So the probability is 10,801,392 / 292,201,338 = 105,896 / 2,864,719 ≈ 0.037.

41.
a) 25 / 292,201,338
b) 25 / 292,201,338
c) 1280 / 571,120,797
d) 7564 / 661,089

42.
a) Intuitively, these should be independent, since the first event seems to have no influence on the
second. In fact we can compute as follows. First p(E1 ) = 1/2 and p(E2 ) = 1/2 by the symmetry
of coin tossing. Furthermore, E1 ∩E2 is the event that the first two coins come up tails and heads,
respectively. Since there are four equally likely outcomes for the first two coins (H H , H T , T H ,
and T T ), p(E1 ∩ E2 ) = 1/4. Therefore p(E1 ∩ E2 ) = 1/4 = (1/2) . (1/2) = p(E1 ) p(E2 ), so the
events are indeed independent.
b) Again p(E1 ) = 1/2. For E2 , note that there are 8 equally likely outcomes for the three coins,
and in 2 of these cases E2 occurs (namely H H T and T H H ); therefore p(E2 ) = 2/8 = 1/4. Thus
p(E1 ) p(E2 ) = (1/2) . (1/4) = 1 / 8. Now E1 ∩ E2 is the event that the first coin comes up tails,
and two but not three heads come up in a row. This occurs precisely when the outcome is T H H

3
, so the probability is 1/8. This is the same as p(E1 ) p(E2 ), so the events are independent.
c) As in part (b), p(E1 ) = 1/2 and p(E2 ) = 1/4. This time p(E1 ∩ E2 ) = 0, since there is no way
to get two heads in a row if the second coin comes up tails. Since p(E1 ) p(E2 ) ̸= p(E1 ∩ E2 ), the
events are not independent.

43.
The door the contestant chooses is chosen at random without knowing where the prize is, but the
door chosen by the host is not chosen at random, because he always avoids opening the door with
the prize. This makes any argument based on symmetry invalid.

44.
1/4 chance of winning with your original selection. Just as in the original problem, the host’s action
did not change this, since he would act the same way regardless of whether your selection was a
winner or a loser. Therefore you have a 1/4 chance of winning if you do not change. This implies
that there is a 3/4 chance of the prize’s being behind one of the other doors. Since there are two
such doors and by symmetry the probabilities for each of them must be the same, your chance of
winning after switching is half of 3/4, or 3/8.

45.
a) 671 / 1296
b) 1 - 3524 / 3624; no
c) The former

7.2
18.
As instructed, we assume that births are independent and the probability of a birth in each day is
1/7. (This is not exactly true; for example, doctors tend to schedule C-sections on weekdays.)
a) The probability that the second person has the same birth day-of-the-week as the first person is
1/7.
b) The probability that all the birth days-of-the-week are different is pn = 67 . 75 ..... 8−n
7 since each
person after the first must have a different birth day-of-the-week from all the previous people in
the group. Note that if n ≥ 8, then pn = 0 since the seventh fraction is 0 (this also follows from
the pigeonhole principle). The probability that at least two are born on the same day of the week
is therefore 1 - pn .
c) We compute 1 - pn for n = 2, 3, ... and find that the first time this exceeds 1 / 2 is when n
= 4, so that is our answer. With four people, the probability that at least two will share a birth
day-of-the-week is 223 / 343, or about 65%.

19.
a) 1 / 12
11 10
b) 1 - 12 . 12 ..... 13−n
12

4
c) 5

20.
If n people are chosen at random (and we assume 366 equally likely and independent birthdays,
as instructed), then the probability that none of them has a birthday today is (365 / 366)n . The
question asks for the smallest n such that this quantity is less than 1 / 2. We can determine this by
trial and error, or we can solve the equation (365 / 366)n = 1 / 2 using logarithms. In either case,
we find that for n ≤ 253, (365/366)n > 1 / 2, but (365 / 366)254 ≈ .4991. Therefore the answer is
254.

21.
The smallest number of people you need to choose at random so that the probability that at least
two of them were both born on April 1 exceeds 1/2 is 614.

22.
a) Given that we are no longer close to the year 1900, which was not a leap year, let us assume that
February 29 occurs one time every four years, and that every other date occurs four times every
four years. A cycle of four years contains 4 . 365 + 1 = 1461 days. Therefore the probability that
a randomly chosen day is February 29 is 1 / 1461, and the probability that a randomly chosen day
is any of the other 365 dates is each 4 / 1461.
b) We need to compute the probability that in a group of n people, all of them have different
birthdays. Rather than compute probabilities at each stage, let us count the number of ways to
choose birthdays from the four-year cycle so that all n people have distinct birthdays. There are
two cases to consider, depending on whether the group contains a person born on February 29. Let
us suppose that there is such a leap-day person; there are n ways to specify which person he is to
be. Then there are 1460 days on which the second person can be born so as not to have the same
birthday; then there are 1456 days on which the third person can be born so as not to have the same
birthday as either of the first two, as so on, until there are 1468 - 4n days on which the nth person
can be born so as not to have the same birthday as any of the others. This gives a total of n . 1460 .
1456 ... (1468 - 4n) ways in all. The other case is that in which there is no leap-day birthday. Then
there are 1460 possible birthdays for the first person, 1456 for the second, and so on, down to 1464 -
4n for the nth . Thus the total number of ways to choose birthdays without including February 29 is
1460 . 1456 ...(1464 - 4n). The sum of these two numbers is the numerator of the fraction giving the
probability that all the birthdays are distinct. The denominator is 1461n , since each person can have
any birthday within the four-year cycle. Putting this all together, we see that the probability that
there are at least two people with the same birthday is 1 - n.1460.1456...(1468.4n)+1460.1456...(1464−4n)
1461n

7.3
9.
a) 0.740
b) 0.260

5
c) 0.002
d) 0.998

10.
p(P |A)p(A) (0.97)(0.04)
a) p(A|P ) = p(P |A)p(A)+p(P |A)p(A)
= (0.97)(0.04)+(0.02)(0.96) ≈ 0.669
b) p(A|P ) = 1 - p(A|P ) ≈ 1 - 0.669 = 0.331
p(P |A)p(A) (0.03)(0.04)
c) p(A|P ) = p(P |A)p(A)+p(P |A)p(A)
≈ (0.03)(0.04)+(0.98)(0.96) ≈ 0.001
d) p(A|P ) = 1 - 0.001 = 0.999

11.
0.724

12.
Let E be the event that a 0 was received; let F1 be the event that a 0 was sent; and let F2 be the
event that a 1 was sent. F2 = F1 . Then we are told that p(F2 ) = 1/3, p(F1 ) = 2/3, p(E|F1 ) = 0.9,
and p(E|F2 ) = 0.2. a) p(E) = p(E|F1 )p(F1 ) + p(E|F2 )p(F2 ) = 0.9 . (2/3) + 0.2 . (1/3) = 2/3.
b) We use Bayes’ theorem:
p(F1 |E) = 0.9

13.
p(F1 |E) = 3 / 17

14.
(3/8)(1/2)
p(F2 |E) = (2/7)(1/6)+(3/8)(1/2)+(1/2)(1/3) = 7 / 15

15.
a) 1 / 3
b) p(M = j | W = k) = 1 if i, j, and k are distinct; p(M = j | W = k) = 0 if j = k or j = i; p(M =
j | W = k) = 1 / 2 if i = k and j ̸= i
c) 2 / 3
d) You should change doors, because you now have a 2 / 3 chance to win by switching.

16.
Let L be the event that Ramesh is late, and let B, C , and O (standing for “omnibus”) be the
events that he went by bicycle, car, and bus, respectively. We are told that p(L | B) = 0.05, p(L |
C) = 0.50, and p(L | O) = 0.20. We are asked to find p(C | L).
a) We are to assume here that p(B) = p(C) = p(O) = 1/3. Then by the generalized version of
Bayes’ theorem, p(C|L) = 2 / 3 b) Now we are to assume here that p(B) = 0.60, p(C) = 0.30, p(O)
= 0.10. Then by the generalized version of Bayes’ theorem, p(C|L) = 3 / 4

6
17.
The definition of conditional probability tells us that p(Fj |E) = p(E∩Fj ) / p(E). For the numerator,
again using the definition of conditional probability,
Pn we have p(E ∩ Fj ) = p(E|Fj ) p(Fj ), as desired.
For the denominator, we show that p(E) = i=1 p(E|Fi ) p(Fi ). The events E ∩ Fi partition the
event E; that is, (E ∩ Fi1 ) ∩ (E ∩ Fi2 ) = when ii ̸= i2 (because the Fi ’s are mutually exclusive),
n
S n
S Pn Pn
and (E ∩ Fi1 ) = E (Because Fi = S). Therefore, p(E) = i=1 p(E ∩ Fi ) = i=1 p(E|Fi )
i=1 i=1
p(Fi )

18.
First compute that p(exciting) = 40/500 = 0.08 and q(exciting) = 25/200 = 0.125. Then we
p(exciting 0.08
compute that r(exciting) = p(exciting)+q(exciting) = 0.08+0.125 ≈ 0.390
Because r(exciting) is less than the threshold 0.9, an incoming message containing “exciting” would
not be rejected.

19.
The method is similar to 18, and the answer is no.

20.
a) p(undervalued) = 0.1 and q(undervalued) = 0.025. So we compute that r(undervalued) =
p(undervalued) 0.01
p(undervalued)+q(undervalued) = 0.01+0.025 ≈ 0.286
Because r(undervalued) is less than the threshold 0.9, an incoming message containing “underval-
ued” would not be rejected.
b) p(stock) = 0.2 and q(stock) = 0.06.
p(stock) 0.2
r(stock) = p(stock)+q(stock) = 0.2+0.06 ≈ 0.769.

21.
Yes, the message will be rejected as spam if the threshold for rejecting spam is 0.9.

7.4
9.
(4n + 6) / 3

20.
We proceed by induction on n. If n = 1 there is nothing to prove, and theQcase n = 2 is Theorem 5.
Qn+1 n
Assume that the equality
Qn holds for n, and consider E ( i=1 Xi ). Let Y = i=1 Xi . By the inductive
hypothesis, E(Y) = i=1 E(Xi ). The fact that all the Xi ’s are mutually independent guarantees
that Y and Xn+1 are independent. Therefore by Theorem 5, E(Y Xn+1 ) = E(Y )E(Xn+1 ).

7
24.
P P
By definition of expectation wePhave E(IA ) = s∈S p(s)IA (s) = s∈A p(s), since IA (s) is 1 when
s ∈ A and 0 when s ∈ / A. But s∈A p(s) = p(A) by definition.

25.
p + (n - 1)p(1 - p)

26.
P∞
By definition, E(X) = k=1 k . p(X = k). Let us write this out and regroup (such regrouping is
valid even if the sum is infinite since all the terms are positive):
E(X) = p(X = 1) + (p(X = 2) + p(X = 2)) + (p(X = 3) + p(X = 3) + p(X = 3)) + ...
= (p(X = 1) + p(X = 2) + p(X = 3) + ...) + (p(X = 2) + p(X = 3) + ...) + (p(X = 3) + ...) +
...
But this is precisely p(A1) + p(A2) + p(A3) + ...

27.
The variance of the number of heads that come up when a fair coin is flipped 10 times is 5 / 2

28.
The variance is 25/18.

37.
P P
E(X) / a = r (r / a) . p(X = r) ≥ r≥a 1 . p(X = r) = p(X ≥ a)

38.
The variance is not 1000 cans; it is 1000 square cans (the units for the variance of X are the square
of the units for X ). So a measure of how much the number of cans filled per day varies is about
the square root of this, or about 31 cans.
a) We have E(X) = 10,000 and we take a = 11,000. Then p(X ≥ 11,000) ≤ 10,000 / 11,000 = 10 /
11. This is not a good estimate.
b) We apply Theorem 8, with r = 1000. The probability that the number of cans filled will differ
from the expectation of 10,000 by at least 1000 is at most 1000 / 10002 = 0.001. Therefore the
probability is at least 0.999 that the plant will fill between 9,000 and 11,000 cans. This is also not
a very good estimate, since if the number of cans filled per day usually differs by only about 31
from the mean of 10,000, it is virtually impossible that the difference would ever be over 30 times
this amount - the probability is much less than 1 in 1000.

39.
a) 10 / 11
b) 0.9999

8
40.
Pn i 1
Pn 1 n(n+1)
Since i=1 n(n+1) = n(n+1) i=1 i = n(n+1) 2 = 12
the probability that the item is not in the list is 1/2. We know that if the item is not in the list, then
2n + 2 comparisons are needed; and if the item is the ith item in the list then 2i + 1 comparisons
are needed. Therefore
Pn the expected number of comparisons is given by
1 i
2 (2n + 2) + i=1 n(n+1) (2i + 1). To evaluate the sum, we use not only the fact that
Pn n(n+1) Pn
i=1 i = 2 but also the fact that i=1 i2 = n(n + 1)(2n + 1)/6 :

1
Pn i
2 (2n+ 2) + i=1 n(n+1) (2i + 1)
2
Pn 2 i
Pn
= n + 1 + n(n+1) i=1 i + n(n+1) i=1 i
2 n(n+1)(2n+1) 1 n(n+1)
=n+1+ n(n+1) 6 + n(n+1) 2
(2n+1) 1
=n+1+ 3 +2
= 10n+11
6

41.
a) Each of the n! permutations occurs with probability 1/n!, so E(X) is the number of comparisons,
averaged over all these permutations.
b) Even if the algorithm continues n - 1 rounds, X will be at most n(n-1) / 2. It follows from the
formula for expectation that E(X) ≤ n(n - 1) / 2.
c) The algorithm proceeds by comparing adjacent elements and then swapping them if necessary.
Thus, the only way that inverted elements can become uninverted is for them to be compared and
swapped.
d) Because X(P) ≥ I(P) for all P, it follows from the definition of expectation that E(X) ≥ E(I).
e) This summation counts 1 for every instance of an inversion.
f) This follows from Theorem 3.
g) By Theorem 2 with n = 1, the expectation of Ij,k is the probability that ak precedes aj in the
permutation. This is clearly 12 by symmetry.
h) The summation in part (f) consists of C(n, 2) = n(n - 1) / 2 terms, each equal to 1 / 2, so the
sum is n(n 1) / 4 . i) From part (a) and part (b) we know that E(X), the object of interest, is at
most n(n - 1) / 2, and from part (d) and part (h) we know that E(X) is at least n(n - 1) / 4, both
of which are Θ(n2 ).

42.
a) Each of the n! permutations occurs with probability 1 / n!, so clearly E(X) is the average number
of comparisons, averaged over all these permutations.
b) The summation considers each unordered pair jk once and contributes a 1 if the j th smallest
element and the k th smallest element are compared (and contributes 0 otherwise). Therefore the
summation counts the number of comparisons, which is what X was defined to be. Note that by
the way the algorithm works, the element being compared with at each round is put between the
two sublists, so it is never compared with any other elements after that round is finished.
c) Take the expectation of both sides of the equation in part (b). By linearity of expectation we
Pn Pn−1
have E(X) = k=2 j=1 E(Ij,k is the stated probability by Theorem 2 (with n = 1 ).

9
d) We prove this by strong induction on n. It is true when n = 2, since in this case the two ele-
ments are indeed compared once, and 2 / (k - j + 1) = 2 / (2 - 1 + 1) = 1. Assume the inductive
hypothesis, and consider the first round of quick sort. Suppose that the element in the first position
is the ith smallest element. If j < i < k , then the j th smallest element gets put into the first sublist
and the k th smallest element gets put into the second sublist, and so these two elements will never
be compared. This happens with probability (k - j - 1) / n in a random permutation. If i = j or
i = k , then the j th smallest element and the k th smallest element will be compared this round.
This happens with probability 2 / n. If i < j , then both the j th smallest element and the k th
smallest element get put into the second sublist and so by induction the probability that they will
be compared later on will be 2 / (k - j + 1). Similarly if i > k . The probability that i < j is (j -
1) / n, and the probability that i > k is (n - k) / n.
Putting this all together, the probability of the desired comparison is

0 . k−j−1
n + 1. n2 + k−j+1
2
.( j−1 n−k
n − n )
which simplifies to 2/(k - j + 1), as desired.

43.
The variance of the number of fixed elements, that is, elements left in the same position, of a
randomly selected permutation of n elements is 1.

10

You might also like