# Handout

```CS 109 - Ron Dror
Winter 2015
Homework 4
Friday February 6th, 2015
Due: Wednesday February 18th, 2015
For each problem, briefly explain/justify how you obtained your answer. Brief explanations of your
answer are necessary to get full credit for a problem even if you have the correct numerical answer. The
explanations help us determine your understanding of the problem whether or not you got the correct answer. Moreover, in the event of an incorrect answer, we can still try to give you partial credit based on the
explanation you provide. It is fine for your answers to include summations, products, factorials, exponentials,
or combinations; you don’t need to calculate those all out to get a single numeric answer.
1. Let F be a joint cumulative distribution over X and Y , so F (x, y) = P (X  x, Y  y). Also,
let FX (x) = P (X  x) and FY (y) = P (Y  y). Suppose we are given the following: F (a, b) =
0.05, F (a, d) = 0.2, F (c, b) = 0.15, F (c, d) = 0.55, FX (a) = 0.45, FY (b) = 0.15 (where a < c and b < d).
(a) Compute P (a < X  c, b < Y  d)
(b) Compute P (X > a, Y  b)
(c) Compute P ({X  a, Y > b} [ {X  c, b < Y  d})
2. Let X and Y be independent random variables, where X ⇠ N (µ1 ,
X Y a
W =
, where a and b are real-valued constants (b 6= 0).
b
2
1)
and Y ⇠ N (µ2 ,
2
2 ).
Let
(a) What is the distribution (along with parameter values) for W ? Show how you derived your
(b) A random variable Z is said to be standardized if it’s expected value is 0 and its variance is 1.
For what values of a and b will W be standardized?
3. The joint probability density of continuous random variables W and Z is given by
fW,Z (w, z) = c 3w2 z 2 + z
where 0 < w < 1, 0 < z < 1
(a) What is the value of c in order for fW,Z (w, z) to be a valid probability density function
(b) Are W and Z independent? Explain why or why not.
(c) What is the marginal density function of W ?
(d) What is P (W > Z)?
(e) What is P (W > 0.5|Z > 0.5)?
(f) What is E[W ]?
4. All Stanford CS majors are required to choose a specialization to complete the major (we will assume
at most one specialization). 20% of CS students choose the Graphics track, 35% choose the HumanComputer Interaction (HCI) track, 40% choose the Artificial Intelligence track (wheee!), and 5% are
undecided. If 17 random CS students are asked which, if any, specialization they are planning to
complete, what is the probability that exactly 5 students will have chosen the Graphics track, 6
will have chosen the HCI track, 4 will have chosen the Artificial Intelligence track, and 2 will be
undecided?
5. A web site historically receives requests at an average rate of 15 per minute, where each request is
twice as likely to come from a bot as a human. Compute the conditional probability that at most 3
requests come from humans in a particular minute if 12 requests from bots are received in that same
minute.
1 of 3
CS 109 - Ron Dror
Winter 2015
Homework 4
6. The Stanford Stadium would like to track how many students attend football games each the quarter.
Let Xi be the total student attendance at game i where Xi ⇠ N (25000, 100000) for all i. Assume that
all Xi are independent of each other.
Note: We call the Xi s I.I.D. in such situations.
(a) The Stadium has only prepared 75500 tickets to sell over the course of the next three games
(75500 tickets total, not per game). What is the probability that total student attendance over
the next three games will exceed 75500, meaning that the Stadium will run out of tickets and
need to print more?
(b) What is the probability that the number of students attending a game exceeds 24800 in at least
4 of the next 5 games?
7. A robot is located at the center of a square world that is 8 kilometers on each side. A package
is dropped o↵ in the robot’s world at a point (x,y) that is uniformly (continuously) distributed in
the square. The robot’s starting location is designated to be (0,0) and the robot can only move
up/down/left/right parallel to the sides of the square. Thus, the distance the robot must get to the
package at point (x,y) is |x| + |y|. Let D = the distance the robot travels to get to the package.
Compute E[D].
8. Choose a number X at random from the set of numbers {1, 2, 3, 4}. Now choose a number at random
from the subset no larger than X, that is from {1, . . . , X}. Let Y denote the second number chosen.
(a) Determine the joint probability mass function of X and Y . Your answer should be a function
fX,Y (i, j) = P (X = i, Y = j).
(b) Determine the conditional mass function P (X = i|Y = j) as a function of i and j.
9. Say we have two independent variables X and Y such that X ⇠ Geo(p) and Y ⇠ Geo(p). Mathematically derive an expression for P (X = k|X + Y = n).
10. A mystery function random chance() returns either true or false with unknown probability. Let X
be the probability of random chance() returning true when called. We believe initially that the
prior probability (before seeing any results of calling the function) for X is a Beta distribution, where
1
E[X] = 0.5 and Var(X) = 52
(a) What are the values of the parameters a and b (where a, b > 1) of the prior Beta distribution for
X?
(b) Now say that we call 3 times, obtaining 2 trues and 1 false. What is the form and parameters of
the posterior distribution of (X|2 trues and 1 false)?
(c) What is E[X|2 trues and 1 false]?
(d) What is Var(X|2 trues and 1 false)?
11. Consider a series of strings that independently get hashed into a hash table. Each such string can be
sent to any one of k + 1 buckets (numbered from 0 to k). Let index i denote the ith bucket. A string
k
P
will independently get hashed to bucket i with probability pi , where
pi = 1. Let N denote the
i=0
number of strings that are hashed until one is hashed to any bucket other than bucket 0. Let X be
the number of that bucket (i.e., the bucket not numbered 0 that receives a string).
(a) Find P (N = n), for n
1
(b) Find P (X = j), for j = 1, 2, . . . k
(c) Find P (N = n, X = j), for n
1 and j = 1, 2, . . . k. Are N and X independent?
2 of 3
CS 109 - Ron Dror
Winter 2015
Homework 4
12. Consider a bit string of length n, where each bit is independently generated and has probability p of
being a 1. We say that a bit switch occurs whenever a bit di↵ers from the one preceding it in the
string (if there is a preceding bit). For example, if n = 5, and we have the bit string 11010, then there
are 3 bit switches. Find the expected number of bit switches in a string of length n.
Hint: You might find it helpful to use a set of indicator variables that are defined in terms of whether
a bit switch occurred in each position of the string.
Interesting Background: The number of bit switches can be one indicator of how compressible a
string might be: for example if the bit string represented a file that we were trying to ZIP
13. A company is running some diagnostics on its three most important algorithms. Each algorithm’s
running time in seconds is independently and identically distributed as an exponential random variable
with parameter .
(a) What is the probability that the first algorithm to finish finishes in less than a seconds? Your
answer should be in terms of a and .
(b) What is the probability that the last algorithm to finish finishes in less than a seconds? Your
answer should be in terms of a and .
3 of 3
```