hw09 Sol

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

CS 70 Discrete Mathematics and Probability Theory

Fall 2024 Hug, Rao HW 09

1 Probability Potpourri
Note 13 Provide brief justification for each part.
Note 14
(a) For two events A and B in any probability space, show that P[A \ B] ≥ P[A] − P[B].
(b) Suppose P[D | C] = P[D | C], where C is the complement of C. Prove that D is independent of
C.
(c) If A and B are disjoint, does that imply they’re independent?

Solution:

(a) It can be helpful to first draw out a Venn diagram:

P[A \ B] P[A ∩ B] P[B \ A]

We can see here that P[A] = P[A ∩ B] + P[A \ B], and that P[B] = P[A ∩ B] + P[B \ A].
Looking at the RHS, we have

P[A] − P[B] = (P[A ∩ B] + P[A \ B]) − (P[A ∩ B] + P[B \ A])


= P[A \ B] − P[B \ A]
≤ P[A \ B]

(b) Using the total probability rule, we have

P[D] = P[D ∩C] + P[D ∩C] = P[D | C] · P[C] + P[D | C] · P[C].

But we know that P[D | C] = P[D | C], so this simplifies to

P[D] = P[D | C] · (P[C] + P[C]) = P[D | C] · 1 = P[D | C],

which defines independence.

CS 70, Fall 2024, HW 09 1


(c) No; if two events are disjoint, we cannot conclude they are independent. Consider a roll of
a fair six-sided die. Let A be the event that we roll a 1, and let B be the event that we roll
a 2. Certainly A and B are disjoint, as P[A ∩ B] = 0. But these events are not independent:
P[B | A] = 0, but P[B] = 1/6.
Since disjoint events have P[A ∩ B] = 0, we can see that the only time when disjoint A and B
are independent is when either P[A] = 0 or P[B] = 0.

2 Independent Complements
Note 14 Let Ω be a sample space, and let A, B ⊆ Ω be two independent events.

(a) Prove or disprove: A and B must be independent.


(b) Prove or disprove: A and B must be independent.
(c) Prove or disprove: A and A must be independent.
(d) Prove or disprove: It is possible that A = B.

Solution:

(a) True. A and B must be independent:


P[A ∩ B] = P[A ∪ B] (by De Morgan’s law)
= 1 − P[A ∪ B] (since P[E] = 1 − P[E] for all E)
= 1 − (P[A] + P[B] − P[A ∩ B]) (union of overlapping events)
= 1 − P[A] − P[B] + P[A]P[B] (since A and B are independent)
= (1 − P[A])(1 − P[B])
= P[A]P[B] (since P[E] = 1 − P[E] for all E)

(b) True. A and B must be independent:


P[A ∩ B] = P[A − (A ∩ B)]
= P[A] − P[A ∩ B]
= P[A] − P[A]P[B]
= P[A](1 − P[B])
= P[A]P[B]

(c) False in general. If 0 < P[A] < 1, then P[A ∩ A] = P[∅] = 0 but P[A]P[A] > 0, so P[A ∩ A] ̸=
P[A]P[A]; therefore A and A are not independent in this case.
(d) True. To give one example, if P[A] = P[B] = 0, then P[A ∩ B] = 0 = 0 × 0 = P[A]P[B], so A
and B are independent in this case. (Another example: If A = B and P[A] = 1, then A and B are
independent.)

CS 70, Fall 2024, HW 09 2


3 Monty Hall’s Revenge
Note 13 Due to a quirk of the television studio’s recruitment process, Monty Hall has ended up drawing all
Note 14 the contestants for his game show from among the ranks of former CS70 students. Unfortunately
for Monty, the former students’ amazing probability skills have made his cars-and-goats gimmick
unprofitable for the studio. Monty decides to up the stakes by asking his contestants to generalize
to three new situations with a variable number of doors, goats, and cars:

(a) There are n doors for some n > 2. One has a car behind it, and the remaining n − 1 have goats.
As in the ordinary Monty Hall problem, Monty will reveal one door with a goat behind it after
you make your first selection. Compute the probability of winning if you switch, as well as the
probability of winning if you don’t switch, and compare the results.
(Hint: Think about the size of the sample space for the experiment where you always switch.
How many of those outcomes are favorable?)
(b) Again there are n > 2 doors, one with a car and n − 1 with goats, but this time Monty will
reveal n − 2 doors with goats behind them instead of just one. How does switching affect the
probability of winning in this modified scenario?
(c) Finally, imagine there are k < n − 1 cars and n − k goats behind the n > 2 doors. After you
make your first pick, Monty will reveal j < n − k doors with goats. What values of j, k max-
imize the relative improvement in your probability of winning if you choose to switch? (i.e.
what j, k maximizes the ratio between your probability of winning when you switch, and your
probability of winning when you do not switch?)

Solution:
Throughout the solution, we will refer to W as the event that the contestant wins, and PS [W ]
and PN [W ] as the probabilities of this event happening if the contestant is (S)witching or (N)ot
switching, respectively.

(a) PN [W ] = 1/n since only one out of n initial choices gets us the car. Under the switching
strategy two things can happen: Either the first choice hits the car, and so switching (to any
of the remaining n − 2 doors) will inevitably get us the goat, or our first choice picks a goat,
leaving one of the remaining n−2 doors with the car. This sequence of choices—first choosing
from one of n doors, then switching to one of n − 2 remaining doors—gives us a sample
space of size n(n − 2). If we divide the number of favorable outcomes by the total number of
outcomes, we get

 

PS [W ] =  (n − 1) · 1 / n(n − 2)
 
| {z } |{z} | {z }
first choice = goat second choice = car total # of choices
n−1 1 n−1
= = ·
n(n − 2) n n − 2

CS 70, Fall 2024, HW 09 3


which is larger than PN [W ] = 1/n (ever so slightly so the larger n becomes, which demonstrates
the intuitive fact that Monty’s help gets decreasingly helpful the more doors there are), so
switching doors is the better strategy.
(b) PN [W ] = 1/n remains unchanged. The same approach as in part (a) yields the same numerator
as before. For the denominator, we need to figure out the size of the sample space for the
experiment where we first pick a door at random, then switch. Again, there are n ways of
making the first choice. Once Monty reveals n − 2 other doors, though, there is only one
remaining option for us to switch to. Thus the denominator is much smaller:
 

PS [W ] =  (n − 1) · 1 / n·1
 
| {z } |{z} |{z}
first choice = goat second choice = car total # of choices

n−1 1
= = 1−
n n
so switching is again the better strategy.
(c) Now PN [W ] = k/n since k doors hide a car. Reasoning about sample spaces in the same way
we did in part (b) gives us a way to compute the denominator of PS [W ]. However, now the
numerator (number of favorable outcomes in the case where we switch) changes too:
 

PS [W ] =  k · k−1 + (n − k) · k  / n(n − j − 1)
 
|{z} | {z } | {z } |{z} | {z }
first choice = car second choice = car first choice = goat second choice = car total # of choices
k(n − 1) k n−1
= = · .
n(n − j − 1) n n − j − 1

From here we see that PS [W ]/PN [W ] = n−n−1j−1 , which is maximal if j = n − k − 1. In other


words, if Monty reveals all but one goat (which he does in the original show where n = 3, k = 1
and j = 1 = n − k − 1), then the contestant can increase their chances of winning by a factor of
n−1
k (which is a factor of 2 in the original show). In particular, the largest relative advantage of
switching is achieved when k = 1.

4 Cliques in Random Graphs


Note 13 Consider the graph G = (V, E) on n vertices which is generated by the following random process:
Note 14 for each pair of vertices u and v, we flip a fair coin and place an (undirected) edge between u and
v if and only if the coin comes up heads.

(a) What is the size of the sample space?


(b) A k-clique in a graph is a set S of k vertices which are pairwise adjacent (every pair of vertices
is connected by an edge). For example, a 3-clique is a triangle. Let ES be the event that a set S
forms a clique. What is the probability of ES for a particular set S of k vertices?

CS 70, Fall 2024, HW 09 4


(c) Suppose that V1 = {v1 , . . . , vℓ } and V2 = {w1 , . . . , wk } are two arbitrary sets of vertices. What
conditions must V1 and V2 satisfy in order for EV1 and EV2 to be independent? Prove your
answer.
(d) Prove that nk ≤ nk . (You might find this useful in part (e)).


(e) Prove that the probability that the graph contains a k-clique, for k ≥ 4log2 n + 1, is at most 1/n.
Hint: Use the union bound.

Solution:

(a) Between every pair of vertices, there is either an edge or there isn’t. Since there are two choices
n
for each of the n2 pairs of vertices, the size of the sample space is 2(2) .


(b) For a fixed set of k vertices to be a k-clique, all of the 2k pairs of those vertices have to be

k
connected by an edge. The probability of this event is 1/2(2) .
(c) EV1 and EV2 are independent if and only if V1 and V2 share at most one vertex: If V1 and V2
share at most one vertex, then since edges are added independently of each other, we have
P[EV1 ∩ EV2 ] = P[all edges in V1 and all edges in V2 are present]
 (|V1 |)  (|V2 |)
1 2 1 2
= ·
2 2
= P[EV1 ] · P[EV2 ].
Conversely, if V1 and V2 share at least two vertices, then their intersection V3 = V1 ∩V2 has at
least 2 elements, so we have
 (|V3 |)  (|V1 |)−(|V3 |)  (|V2 |)−(|V3 |)
1 2 1 2 2 1 2 2
P[EV1 ∩ EV2 ] = · ·
2 2 2
|V | |V |
 ( 1 )+( 2 )−( 3 ) |V |
1 2 2 2
= ̸= P[EV1 ] · P[EV2 ].
2

(d) The algebraic solution is an application of the definition of nk :



 
n n! n · (n − 1) · · · (n − k + 1)
= =
k (n − k)!k! k!
≤ n · (n − 1) · · · (n − k + 1)
≤ nk

(e) Let AS denote the event that S is a k-clique, where S ⊆ V is of size k. Then, the event that the
graph contains a k-clique can be described as the union of AS ’s over all S ⊆ V of size k. Using
the union bound,
 
[ 1
P AS  ≤ ∑ P[AS ] = ∑ .
S⊆V,|S|=k
(k )
S⊆V,|S|=k 2 2
S⊆V,|S|=k

CS 70, Fall 2024, HW 09 5


n
Now, since there are k ways of choosing a subset S ⊆ V of size k, the right-hand side of the
above equality is
n n
k k nk nk nk nk 1 1
k = k(k−1)/2
≤ k ≤ k = 2 log n k = 2k = k ≤ .
2(2) 2 2(k−1)/2 2(4 log n+1−1)/2 (2 ) n n n

5 Symmetric Marbles
Note 14 A bag contains 4 red marbles and 4 blue marbles. Rachel and Brooke play a game where they draw
four marbles in total, one by one, uniformly at random, without replacement. Rachel wins if there
are more red than blue marbles, and Brooke wins if there are more blue than red marbles. If there
are an equal number of marbles, the game is tied.

(a) Let A1 be the event that the first marble is red and let A2 be the event that the second marble is
red. Are A1 and A2 independent?
(b) What is the probability that Rachel wins the game?
(c) Given that Rachel wins the game, what is the probability that all of the marbles were red?

Now, suppose the bag contains 8 red marbles and 4 blue marbles. Moreover, if there are an equal
number of red and blue marbles among the four drawn, Rachel wins if the third marble is red, and
Brooke wins if the third marble is blue. All other rules stay the same.

(d) What is the probability that the third marble is red?


(e) Given that there are k red marbles among the four drawn, where 0 ≤ k ≤ 4, what is the proba-
bility that the third marble is red? Answer in terms of k.
(f) Given that the third marble is red, what is the probability that Rachel wins the game?

Solution:

(a) They are not independent; removing one red marble lowers the probability of the next marble
being red.
(b) Let p be the probability that Rachel wins. Since there are an equal number of red and blue
marbles, by symmetry, the probability that Rachel wins and the probability that Brooke wins
is the same. Thus, the probability that there is a tie is 1 − p − p = 1 − 2p.
We now compute the probability that there is a tie. For there tobe a tie, two of the four marbles
need to be red. There are 4 ways to pick 4 marbles, and 42 42 to pick 2 red and blue marbles,
8

respectively, giving a probability of


4 4
2 2 36 18
8
= = .
4
70 35

CS 70, Fall 2024, HW 09 6


18 17
We conclude that 1 − 2p = 35 . Solving for p gives p = .
70
(c) Let A be the event that there are 3 red marbles drawn, and let B be the event that there are 4 red
marbles drawn. We wish to compute
P[B ∩ (A ∪ B)] P[B]
P[B | (A ∪ B)] = = .
P[A ∪ B] P[A] + P[B]
Similar to the calculation in part (b), the probability that there are 3 red marbles drawn is
(43)(41) 16 (4)(4) 1
8 = 70 , and the probability that there are 4 red marbles drawn is 4 8 0 = 70 , giving a final
(4) (4)
1 1
answer of 16 70 1 = .
70 + 70 17
(d) By symmetry, the probability that the third marble is red is the same as the probability that
the first marble is red, or the same as any marble being red. One way to see this is to imagine
drawing the four marbles in order, then moving the first marble drawn to the third position.
This is another way to draw four marbles that yields the same distribution.
There are 8 red marbles, and 12 marbles in total. Thus, the probability that the third marble is
8 2
red is 12 = .
3
(e) We are given that there are k red marbles among the 4 drawn. By symmetry, each marble has
k
the same probability of being red, so the probability that the third marble is red is .
4
(f) The only way for Rachel to lose the game given that the third marble is red is if all the other
marbles are blue. The probability that the third marble is red and all the other marbles are
4 3 8 2 8 8
blue is 12 · 11 · 10 · 9 = 495 , and the probability that the third marble is red is 12 = 23 , so the
8
495 4
probability that Rachel loses given that the third marble is red is 2 = 165 , and the probability
3
161
that Rachel wins given that the third marble is red is .
165

6 Socks
Note 13 Suppose you have n different pairs of socks (n left socks and n right socks, for 2n individual socks
Note 14 total) in your dresser. You take the socks out of the dresser one by one without looking and lay
them out in a row on the floor. In this question, we’ll go through the computation of the probability
that no two matching socks are next to each other.

(a) We can consider the sample space as the set of length 2n permutations. What is the size of the
sample space Ω, and what is the probability of a particular permutation ω ∈ Ω?
(b) Let Ai be the event that the ith pair of matching socks are next to each other. Calculate P[Ai ].

CS 70, Fall 2024, HW 09 7


(c) Calculate P[A1 ∩ ... ∩ Ak ] for an arbitrary k ≥ 2. (Hint: try using a counting based approach.)

(d) Putting these all together, calculate the probability that there is at least one pair of matching
socks next to each other. Your answer can (and should) be expressed as a summation. (Hint:
use Inclusion/Exclusion.)

(e) Using your answer from the previous part, what is the probability that no two matching socks
are next to each other? (This should follow directly from your answer to the previous part, and
also can be left as a summation.)

Solution:

(a) We have a uniform sample space of size (2n)!.

(b) Consider the ith matching pair as a single, condensed unit. As an example, in for n = 3, an
original permutation could look like 132213. Let us condense both the 2’s together, and label
it as B. Then, a resulting string would look like 13B13. Then, there are 2n − 1 ’units’ left that
we can order, and thus (2n − 1)! ways to order them. Also, when we condensed them, either
the left sock or the right sock could’ve came first, so there are 2 ways to condense this pair.
Thus, the probability is 2(2n−1)!
(2n)! .

(c) We will employ an analogous strategy to the previous part. We will consider all k of these
matching socks. There are 2k ways to condense them. Once condensed, there are (2n − k)!
ways to order the remaining units. Thus, the probability is 2k (2n−k)!
(2n)! .

(d) We look for:

P[A] = P[A1 ∪ A2 ∪ ... ∪ An ]


n
= ∑ P[Ai ] − ∑ P[Ai ∩ A j ] + · · ·
i=1 1≤i< j≤n
n
(2n − 1)! (2n − 2)!
= ∑2· − ∑ 22 · +···
i=1 (2n)! 1≤i< j≤n (2n)!
   
n 1 (2n − 1)! n 2 (2n − 2)!
= 2 · − 2 · +···
1 (2n)! 2 (2n)!
n  
k+1 n (2n − k)!
= ∑ (−1) 2k ·
k=1 k (2n)!
.
(e) This is just the complement of the previous part, which becomes
n   k
k n 2 (2n − k)!
1 − P[A] = ∑ (−1) .
k=0 k (2n)!

CS 70, Fall 2024, HW 09 8

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy