0% found this document useful (0 votes)
38 views10 pages

COMP 2804 - Assignment 4

Uploaded by

Ben Yu
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)
38 views10 pages

COMP 2804 - Assignment 4

Uploaded by

Ben Yu
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/ 10

COMP 2804 — Assignment 4

Due: Sunday April 7th, 11:59 pm.


Assignment Policy:

ˆ Your assignment must be submitted as one single PDF file through Brightspace.

ˆ Late assignments will not be accepted. I will not reply to emails of the type
“my internet connection broke down at 11:53pm” or “my scanner stopped
working at 11:54pm”, or “my dog ate my laptop charger”.

ˆ You are encouraged to collaborate on assignments, but at the level of discussion only.
When writing your solutions, you must do so in your own words.

ˆ Past experience has shown conclusively that those who do not put adequate effort into
the assignments do not learn the material and have a probability near 1 of doing poorly
on the exams.

ˆ When writing your solutions, you must follow the guidelines below.

– You must justify your answers.


– The answers should be concise, clear and neat.
– When presenting proofs, every step should be justified.

Question 1:

ˆ Write your name and student number.


Benjamin Yu 101261937

Question 2:
You are celebrating the end of the semester at your local pub. Being an intrepid computer
scientist, you run a randomized algorithm to determine what you order. Every time the wait
staff asks you your order, you roll 2 fair, six-sided dice and add them together (all rolls are
mutually independent).

ˆ If you roll 11, you order Fibonachos.

ˆ If you roll 6 or 7 you order Newton’s IPA.

ˆ If you roll anything else, you order a Pepys Cola.

1
a) You stay and continue to order until you have the Fibonachos or the IPA, then you
pay your bill and leave. How many Pepys Cola do you expect to drink?

Letting F represent the probability of ordering Fibonachos and N represent the prob-
ability of ordering Newton’s IPA, we have
2
P (F ) = 36
5 6 11
P (N ) = 36 + 36 = 36 .

Thus, knowing that F and N are exclusive events, we have


P (F ∪ N ) = P (F ) + P (N ) = 13
36
.

The expected number of trials is given by


E = P1 = 36
13
≈ 2.769.

Subtracting the last trial, which will be either a Nachos or an IPA, we get
an expected 1.769 Colas.
b) You worked hard this semester, so you decide to treat yourself to an extra IPA. In
the remaining questions, you keep ordering until you order two Newton’s IPA in total,
or a single order of Fibonachos. What is the probability that you end up eating the
Fibonachos?

To start, we note the conditional probabilities of rolling a Fibonachos and rolling an


IPA given that we roll one or the other:

P (F )
P (F |F ∪ N ) =
P (F ∪ N )
2 36
= ·
36 13
2
=
13

P (N |F ∪ N ) = 1 − P (F |F ∪ N )
2
=1−
13
11
=
13
We can divide our event of eating the Fibonachos up into two cases:
Case 1: Roll Fibonachos first, before rolling any IPA
2
In this case, we’re just looking for P (F |F ∪ N ), so we get 13 .

2
Case 2: Roll IPA first, and then roll Fibonachos
We note that P (F ∩ N |F ∪ N ) gives us two possible options: rolling Fibonachos first
or rolling IPA first. However, we only want one of those options. So, the probability
for this case is P (F ∩ N |F ∪ N )/2.
Noting independence of F and N , we have

P (F ∩ N |F ∪ N ) = P (F |F ∪ N ) · P (N |F ∪ N )
2 11
= ·
13 13
22
=
169
11
Thus, our probability for case 2 is 169
.

Adding the cases together since they’re mutually exclusive, we get that
2 11
The probability of eating the Fibonachos is 13 + 169 = 0.2189.

c) What is the probability that you drink at least one IPA? What is the probability that
you drink two IPA’s?

The probability of drinking at least one IPA is given by 1 minus the probability that
2
Fibonachos are rolled first, which was determined in the previous part to be 13 . Thus,
2 11
we have P (N ≥ 1) = 1 − 13 = 13 .

The probability of drinking two IPAs, noting independence of rolls, is given by

P (N ∩ N |F ∪ N ) = P (N |F ∪ N ) · P (N |F ∪ N )
11 11
= ·
13 13
121
=
169
d) What is the expected number of Pepys Cola that you will drink?

e) The pub graciously offers free colas, but the Fibonachos cost $20 and Newton’s IPA
are $8 each. What is the expected value of the bill at the end of the night?

f) Bonus: You stay at the pub until you order two Newton’s IPA in a row, then you pay
your bill and leave. How many times would you expect to order in total?

3
Question 3: You are ordering CPUs from a chip manufacturer, the same as Question 2 from
the previous assignment. As in the last assignment, the chip manufacturer manufactures 1000
CPUs. 75 of the CPUs are defective, and are distributed uniformly at random throughout
the 1000 CPUs. You purchase 150 CPUs from the company. Let X be the number of
defective CPUs you purchase. You are going to find E(X) using three different methods.

a) Determine E(X) using the definition of expected value, that is


75
X
E(X) = k · P r(X = k).
k=0

Since this expression will be difficult to simplify, you may leave it as a summation. Or
you can use Wolfram Alpha to get the solution.

(75k )·(150−k
925
)
P r(X = k) = 1000
( 150 )

Thus,

75
X
E(X) = k · P r(X = k)
k=0
75 75 925
 
X k
· 150−k
= k· 1000

k=0 150

= 11.25

b) We will give each defective CPUs a number 1 through 75. Define indicator random
variables A1 , A2 , A3 , ..., A75 such that for i ∈ {1..75}:
(
Ai = 1 if you purchased defective CPU number i, and
Ai = 0 otherwise.

Determine E(X) using these indicator random variables.

150
E(Ai ) = P (Ai = 1) = 1000
since there are 150 total spots for computer i to possibly go.

There are 75 such indicator variables with the same expected value, and so the total
expected value is given by

150
E(X) = 75 · 1000
= 11.25.

4
c) Define indicator random variables C1 , C2 , C3 , ..., C150 representing the CPUs that you
purchased. For i ∈ {1..150}, let:
(
Ci = 1 if CPU i is defective
Ci = 0 otherwise.

Determine E(X) using these indicator random variables.

75
E(Ai ) = P (Ai = 1) = 1000
since there are 75 defective computers out of 1000 total.

There are 150 such indicator variables with the same expected value, and so the total
expected value is given by

75
E(X) = 150 · 1000
= 11.25.

Question 4: We roll a fair red die and a fair blue die. We define the following random
variables.

(
1 if the red die is even
R=
0 otherwise

(
1 if the blue die is 3 or less
B=
0 otherwise

(
1 if the sum of both dice is even
S=
0 otherwise

It should be clear that R and B are independent random variables, so you do not have
to prove that.

a) Are R, B, and S pairwise independent?

Checking R and S:
P (R) = 12
P (S) = 12

1
P (R ∩ S) = 4
= P (R) · P (S) - intersection probability obtained from counting rolls
from a table

5
Thus, R and S are independent.

Checking B and S:
P (B) = 12
P (S) = 12

P (R ∩ S) = 41 = P (R) · P (S) - intersection probability obtained from counting rolls


from a table
Thus, B and S are independent.

Since all three pairs of events are independent, the three events are pairwise
independent.

b) Are R, B, and S mutually independent?


P (R) = 12
P (B) = 12
P (S) = 12

3 1
P (R ∩ B ∩ S) = 36 = 12 intersection probability obtained from counting rolls from a
table
Since P (R ∩ B ∩ S) ̸= P (R) · P (B) · P (S), the events are not mutually indepen-
dent.

Question 5:
There is a song-writing contest at your local radio station. Everyone who enters this
contest writes their song using Sing-GPT, an AI song writing service, to generate their songs.
Of course, since Sing-GPT is not terribly original, it only generates 100 different songs. There
are 50 people entering into the contest, each with a uniformly random generated song chosen
from the 100 different songs available.
Hint: For both questions below, use indicator random variables.

a) Let X be the number of different songs entered into the contest. What is E(X)?

Define indicator random variables S1 , S2 , S3 , ..., S100 representing the different songs.
For i ∈ {1..150}, let:
(
Si = 1 if song i is entered
Si = 0 otherwise.

6
We can see that

P (Si = 1) = 1 − P (Si = 0)
99 50
=1−( )
100

99 50
Thus, E(X) = 100 · (1 − ( 100 ) ) ≈ 39.4994.

b) If a song is entered more than once, it is ejected from the contest. What is the expected
number of songs to be ejected?

The expected number of songs to be ejected is given by the total number of songs
minus the expected number of different songs, that is,
50 − E(X) ≈ 50 − 39.4994 = 10.5006 repeated songs.

7
The next two questions use the following definition. If X is a random variable that can
take any value n where n is an integer and n ≥ 1, and if A is an event, then the conditional
expected value E(X|A) is defined as


X
E(X|A) = k · Pr(X = k|A).
k=1

Question 6: A standard deck is a deck of 52 cards. If R = {A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K}


is the set of possible ranks and S = {♡, ♢, ♠, ♣} are the set of suits, then a deck of 52 cards
D = S × R = {(♡, A), (♢, A), (♠, A), (♣, A), (♡, 2), (♢, 2), (♠, 2), (♣, 2), ..., (♠, K), (♣, K)}.
The ranks J, Q, and K are known as “face cards”. Let D be a standard deck of cards. We
are going to define a value system loosely based on the rules of Blackjack. For a card c ∈ D,
let the value of X(c) be equal to its rank if the rank is an integer, 11 if the rank is A and
10 if the rank is in {J, Q, K}. For example, if X(c) random variable mapping the card to
its value, then X(♡, A) = 11, X(♠, A) = 11, X(♠, 7) = 7, X(♠, 8) = 8, X(♠, K) = 10, etc.
Assume you are dealt 2 cards.

a) What is the expected total value of the cards in your hand?

The expected total value would be the sum of all possible values, divided by 26 since
there are 26 possible pairs. The cards from 2 to 9 each get multiplied by 4 since there
are 4 suits, there are 4 such groups of cards worth 10, and 1 such group worth 11.

Plugging in numbers we get

(( 9k=2 4k) + 10 · 4 · 4 + 11 · 4)/26 ≈ 14.6154 total expected value.


P

b) What is the expected value of your hand given that at least one of your cards has value
10?

c) Let X be the value of the lowest card in your hand, and let Y =“both cards in your
hand have values in the range 2 − 9”. Show that E(X|Y ) = 257
62
≈ 4.15.

I arrived at another, similar, answer with a presumably different approach.


Hopefully my solution warrants partial credit.

Here, we are only working with cards between 2 and 9 inclusive, and thus there are 8
numerical options for cards to be drawn.

We first find the probability of having k as the lowest card.

8
1
There is a 8
chance of drawing k and 2 spots to put it.

There is a 9−k
8
chance of drawing the other card strictly higher than k, as well as a 1
64
chance that both cards drawn are of value k.

Thus, the probability of having k as the lowest card is given by


1 9−k 1
4
· 8 + 64 .

Following the formula for expected value, we have

P9
E(X|Y ) = k=2 k · ( 41 · 9−k
8
+ 1
64
) = 4.1875.

Question 7:
We roll a fair red and blue six-sided die and add them together. Keep rolling until either
the red die comes up as 6 or the blue die comes up as 6, then we stop. Let X be the total
number of times we roll both dice. Let Di be the sum of the red and blue dice on roll i, and
let Y be the sum of all the dice rolls, that is, Y = D1 + D2 + ... + DX .
a) Find E(X).

Defining R to be the event that the red die shows a 6 and B to be the event that the
blue die shows a 6, we have
P (R) = 16
P (B) = 16
P (R ∩ B) = 16 · 16 = 36
1
since the two events are independent of each other.

Also,
P (R ∪ B) = P (R) + P (B) − P (R ∩ B)
1 1 1
= + −
6 6 36
11
=
36

Following the expected trials formula, we get


1
E(X) = P (R∪B) = 36
11
≈ 3.2727.

b) Find E(Y |X = 4). That is, find the sum of all the dice rolls assuming that the first
time you rolled a 6 on either die was the fourth dice roll. Hint: Find the conditional
probability of D1 ..D4 first. You may consider using linearity of expectation as well as
conditional expected value.

9
c) Note that for any roll of the red and blue dice, that Di for all 1 ≤ i ≤ X are inde-
pendent and identically distributed. What this means is that E(D1 ) = E(Di ) for all
values 1 ≤ i ≤ X. Wald’s Identity tells us that if X is the number of die rolls, and the
value of X depends on a stopping condition (which it does in this case), then the ex-
pected sum of all the die rolls E(Y ) = E(X)·E(D1 ). Find E(Y ) using Wald’s Identity.

36
We have from part A that E(X) = 11
.

E(D1 ) is given by the sum of all the dice rolls divided by the number of possible rolls,
that is, P
E(D1 ) = ( 6k=1 k)/6 = 3.5.
Applying the above-given Wald’s Identity, we have

E(Y ) = E(X) · E(D1 )


36
= · 3.5
11
≈ 11.4545

10

You might also like