School of Engineering and Applied Science (SEAS), Ahmedabad University
Probability and Stochastic Processes (MAT 277)
Homework Assignment - 3
Deadline: March 07, 2024
1. Alice and Bob decide to have children until either they have their first girl or they have
k ≥ 1 children. Assume that each child is a boy or girl independently with probability
1/2 and that there are no multiple births.
(a) What is the expected number of female children that they have?
(b) What is the expected number of male children that they have?
Solution
Given the scenario where Alice and Bob decide to have children until they have their
first girl or they have k ≥ 1 children, we analyze the expected number of female and
male children.
1. Expected Number of Female Children (E[F ])
The probability of having a female child is 21 for each birth. The process stops as soon
as they have their first girl, or when they have k children. Therefore, the expected
number of female children is given by the probability of having at least one girl in up
to k attempts:
k
1
E[F ] = 1 −
2
2. Expected Number of Male Children (E[M ])
For the expected number of male children, considering the possibilities of having n male
children before a female child or reaching k male children without a female:
E[M ] = 1 − 2−k
2. You have $1000, and a certain commodity presently sells for $2 per ounce. Suppose
that after one week the commodity will sell for either $1 or $4 an ounce, with these two
possibilities being equally likely.
(a) If your objective is to maximize the expected amount of money that you possess at
the end of the week, what strategy should you employ?
(b) If your objective is to maximize the expected amount of the commodity that you
possess at the end of the week, what strategy should you employ?
1
Solution
Suppose that you buy x ounces during the first week, and then you will have 1000 − 2x
dollars until next week.
(a) Let M denote the amount of money that you possess at the end of the week.
1 1
EM = (1000 − 2x + x) + (1000 − 2x + 4x)
2 2
1
= 1000 + x
2
The expected amount of money would be larger if you bought more during the
first week. Therefore, the best strategy would be to use all your money to get 500
ounces of the commodity and sell them after one week.
(b) Let N denote the amount of the commodity.
1 1000 − 2x 1
EN = (x + 1000 − 2x) + x+
2 4 2
1
= − x + 625
4
The expected amount of the commodity would be smaller if you bought more during
the first week. Therefore, the best strategy would be not to buy anything during
the first week, and spend all the money after one week.
3. A person tosses a fair coin until a tail appears for the first time. If the tail appears on
the nth flip, the person wins 2n dollars. Let X denote the player’s winnings. Show that
E[X] = +∞. This problem is known as the St. Petersburg paradox.
(a) Would you be willing to pay $1 million to play this game once?
(b) Would you be willing to pay $1 million for each game if you could play for as long
as you liked and only had to settle up when you stopped playing?
Solution
This is a loose question, and some of the answers depend on your outlook on things.
Nevertheless, there are some probability observations which should help you decide,
and the question is asking you to isolate those. So, to begin with, we should check that
E(X) = +∞. X is a function of the geometric random variable, “the arrival of the
first tail”. The probability that the first tail arrives at the n-th flip is 2−n , n = 1, 2, . . ..
Since the value of X if the first tail is at flip n is 2n , we find
∞
X ∞
X
n −n
E(X) = 2 ·2 = 1 = +∞.
n=1 n=1
(a) Most people said “no” here, arguing that the probability of recovering your $1,000,000
were very small, approximately 1 in a million, which is correct and reasonable.
2
(b) A lot of people said “no” here, also. However, since the expectation is infinite,
one should look closer. In fact, if you are allowed to pay up at the end and can quit
whenever you wish, then this is virtually giving you a fortune. The only problem is that
in order to realize this gain, you will have to wait a long time. The longer you play,
the more favorable the game is (that is when you choose beforehand how long you will
play it). People have worked what a fair entry price is, and it actually grows with the
number of plays. That is, if you play for n games, you shouldn’t pay just $1,000,000
×n, but rather $1,000,000 ×n log2 (n).
4. Prove that E[X k ] ≥ E[X]k for any even integer k ≥ 1.
Solution:
We aim to prove that for any even integer k ≥ 1 and for a random variable X, the
inequality E[X k ] ≥ E[X]k holds, where E[·] denotes the expected value. We utilize
Jensen’s Inequality, which states that for a convex function φ and a random variable
X,
φ(E[X]) ≤ E[φ(X)].
Step 1: Convexity of φ(x) = xk for even k
First, we demonstrate that the function φ(x) = xk is convex for even k. The second
derivative of φ(x) with respect to x is
φ′′ (x) = k(k − 1)xk−2 .
Since k is an even integer and k ≥ 1, the second derivative φ′′ (x) is non-negative for all
x, proving that φ(x) is convex.
Step 2: Application of Jensen’s Inequality
Given that φ(x) = xk is convex for even k, by applying Jensen’s Inequality, we have
φ(E[X]) ≤ E[φ(X)],
which simplifies to
(E[X])k ≤ E[X k ].
Therefore, it is proved that for any even integer k ≥ 1, E[X k ] ≥ E[X]k .
This completes the proof that for even powers, the expected value of the power of a
random variable is greater than or equal to the power of the expected value of the
random variable.
3
5. Suppose we flip a coin n times to obtain a sequence of flips X1 , X2 , . . . , Xn . A streak of
flips is a consecutive subsequence of flips that are all the same. For example, if X3 , X4 ,
and X5 are all heads, there is a streak of length 3 starting at the third flip. (If X6 is
also heads, then there is also a streak of length 4 starting at the third flip.)
(a) Let n be a power of 2. Show that the expected number of streaks of length log2 n+1
is 1 − o(1).
(b) Show that, for sufficiently large n, the probability that there is no streak of length
at least ⌊log2 n − 2 log2 log2 n⌋ is less than 1/n. (Hint: Break the sequence of flips
up into disjoint blocks of ⌊log2 n − 2 log2 log2 n⌋ consecutive flips, and use the event
that one block is a streak is independent of the event that any other block is a
streak)
Solution:
Given a sequence of coin flips X1 , X2 , . . . , Xn , we define a streak to be a consecutive
subsequence where all flips are the same.
Part (a)
For n being a power of 2, we want to find the expected number of streaks of length
log2 n + 1.
Solution:
Let Ek denote the expected number of streaks of length k in n flips. Note that a streak
of length k can start at any of the first n − k + 1 flips. The probability of any given
sequence of k flips forming a streak is 2−k , since each flip is independent and has a
probability of 12 of being either heads or tails. Thus,
Ek = (n − k + 1) · 2−k .
Substituting k = log2 n + 1, we get:
Elog2 n+1 = (n − (log2 n + 1) + 1) · 2−(log2 n+1) .
Simplifying,
1
Elog2 n+1 = (n − log2 n) · 2− log2 n · .
2
Since n is a power of 2, say n = 2m , we have log2 n = m, thus,
1
Elog2 n+1 = (2m − m) · 2−m · .
2
Further simplifying,
m
Elog2 n+1 = 1 − .
2 · 2m
Since m = log2 n, it follows that
4
Elog2 n+1 = 1 − o(1),
as n grows large, since the second term goes to 0.
Part (b)
For large n, we are interested in the probability that there is no streak of length at least
⌈log2 n − 2 log2 log2 n⌉.
Solution:
To solve this, we break the sequence of n flips into blocks of ⌈log2 n − 2 log2 log2 n⌉
consecutive flips. The number of such blocks is approximately ⌈log n−2 nlog log n⌉ .
2 2 2
The probability that a given block does not contain a streak of the specified length is
1 − 2−⌈log2 n−2 log2 log2 n⌉ . Assuming independence between blocks, the probability that no
block contains such a streak is
n
1 − 2−⌈log2 n−2 log2 log2 n⌉
⌈log
2 n−2 log2 log2 n⌉ .
Using the fact that 1 − x ≤ e−x for all x, we can bound this probability from above by
n
− ⌈log ·2−⌈log2 n−2 log2 log2 n⌉
e 2 n−2 log2 log2 n⌉ .
As n becomes large, the exponent goes to 0, and thus the overall probability goes to 1,
meaning the probability of not having such a streak is less than 1/n.
6. Jensen’s Inequality:
(a) Show by induction P that if f : R → R is convex then, for any x1 , x2 , . . . , xn and
λ1 , λ2 , . . . , λn with ni=1 λi = 1,
n
! n
X X
f λ i xi ≤ λi f (xi ) .
i=1 i=1
(b) Use Eqn. (2.2) to prove that if f : R → R is convex then
E[f (X)] ≥ f (E[X])
for any random variable X that takes on only finitely many values.
Solution:
Part (a)
We want to show by induction that if f : R → R is convex, then for any x1 , x2 , . . . , xn
and λ1 , λ2 , . . . , λn with ni=1 λi = 1, we have:
P
n
! n
X X
f λi xi ≤ λi f (xi ).
i=1 i=1
5
Proof:
Base Case: For n = 1, the statement is trivially true since f (λ1 x1 ) = λ1 f (x1 ) for
λ1 = 1.
Inductive Step: Assume the statement is true for n = k. Consider n = k + 1. We have:
k+1
! k
!
X X
f λ i xi =f λk+1 xk+1 + λ i xi
i=1 i=1
k
!
X λi
=f λk+1 xk+1 + (1 − λk+1 ) xi .
i=1
1 − λk+1
By the convexity of f and the inductive hypothesis:
k
! k
!
X λi X λi
f λk+1 xk+1 + (1 − λk+1 ) xi ≤ λk+1 f (xk+1 ) + (1 − λk+1 )f xi
i=1
1 − λk+1 i=1
1 − λk+1
k
X λi
≤ λk+1 f (xk+1 ) + (1 − λk+1 ) f (xi )
i=1
1 − λk+1
k+1
X
= λi f (xi ).
i=1
Thus, by induction, the inequality holds for any n.
Part (b)
To prove that for a convex function f : R → R and a random variable X with a finite
number of values, E[f (X)] ≥ f (E[X]), we use Equation (2.2).
Proof:
Let X take on values x1 , x2 , . . . , xn with probabilities p1 , p2 , . . . , pn respectively. Then
by definition,
n
X n
X
E[X] = p i xi and E[f (X)] = pi f (xi ).
i=1 i=1
Since f is convex and by part (a), we have:
n
! n
X X
f (E[X]) = f p i xi ≤ pi f (xi ) = E[f (X)].
i=1 i=1
Therefore, E[f (X)] ≥ f (E[X]), which completes the proof.
7. Variance:
(a) If E[X] = 3 and V ar(X) = 1, find E[(4X − 1)2 ] and V ar(5 − 2X).
6
(b) Two cards are drawn at random from an ordinary deck of 52 playing cards. If the
two cards display the same suit, you win $2. If they are of the same color only, you
win $1. Otherwise, you lose 50 cents. Calculate the variance of the amount you
win.
(c) Suppose that two teams play a series of games that ends when one of them has
won i games. Suppose that each game played is independently won by team A with
probability p. With i = 2, find the variance of the number of games played, and
1
show that this number is maximized when p = .
2
Solution
Part (a)
Given E[X] = 3 and V ar(X) = 1, we want to find E[(4X − 1)2 ] and V ar(5 − 2X).
Solution:
We use the properties of expected value and variance. The expected value is linear, and
the variance of a constant times a variable is the constant squared times the variance
of the variable.
(a) To find E[(4X − 1)2 ], we expand the square and use linearity of expectation:
E[(4X − 1)2 ] = E[16X 2 − 8X + 1] = 16E[X 2 ] − 8E[X] + 1.
To find E[X 2 ], we use the fact that V ar(X) = E[X 2 ] − E[X]2 , which gives us
E[X 2 ] = V ar(X) + E[X]2 . Substituting the given values:
E[X 2 ] = 1 + 32 = 10.
Therefore,
E[(4X − 1)2 ] = 16(10) − 8(3) + 1 = 161 − 24 = 137.
(b) To find V ar(5 − 2X), we note that adding a constant does not change the variance
and use the property of variance for constants:
V ar(5 − 2X) = 4V ar(X) = 4(1) = 4.
Part (b)
Two cards are drawn at random from an ordinary deck of 52 playing cards with defined
payouts. We calculate the variance of the winnings.
Solution:
We define the random variable W as the amount won. Let’s calculate the probabilities
and corresponding values:
• Same suit (not same color or same rank): P (W = 2) = 4
52
· 12
51
.
7
• Same color (not same suit): P (W = 1) = 26
52
· 24
51
.
• Otherwise: P (W = −0.5) is the remaining probability.
The expected value E[W ] is calculated as:
E[W ] = 2P (W = 2) + 1P (W = 1) − 0.5(1 − P (W = 2) − P (W = 1)).
Then, we calculate E[W 2 ] in a similar way and use it to find the variance:
V ar(W ) = E[W 2 ] − E[W ]2 .
Part (c)
For a series of games played until one team has won i games, we calculate the variance
of the number of games played.
Solution:
Let G denote the number of games played. When i = 2, the series could end in 2 or
3 games. We calculate the probabilities of these outcomes based on team A’s winning
probability p.
P (G = 2) = p2 + (1 − p)2 ,
P (G = 3) = 2p(1 − p).
The expected number of games E[G] and the expected square E[G2 ] are then calculated,
and the variance is found via V ar(G) = E[G2 ] − E[G]2 .
To find the value of p that maximizes V ar(G), we take the derivative of the variance
with respect to p and set it equal to zero. We solve for p to find the maximizing value,
which should be p = 21 .
8. Continuous Random Variables:
1 1
(a) Let X be a uniform random variable on [0, 1]. Determine P r(X ≤ 2
| 4
≤ X ≤ 34 )
and P r(X ≤ 41 | (X ≤ 31 ) ∪ (X ≥ 32 )).
(b) Let X1 , X2 , ..., Xn be independent exponential random variables with parameter 1.
Find the expected value of the k th largest of the n random variables.
(c) We agree to try to meet between 12 and 1 for lunch at our favorite sandwich shop.
Because of our busy schedules, neither of us is sure when we’ll arrive; we assume
that, for each of us, our arrival time is uniformly distributed over the hour. So
that neither of us has to wait too long, we agree that we will each wait exactly 15
minutes for the other to arrive and then leave. What is the probability we actually
meet each other for lunch?
8
Part (a)
1
Let X be a uniform random variable on [0, 1]. We are asked to determine P r(X ≤ 2
|
1
4
≤ X ≤ 34 ) and P r(X ≤ 14 | (X ≤ 31 ) ∪ (X ≥ 23 )).
Solution:
(a) The probability that X is less than or equal to 12 given that it is between 14 and 34 is
simply the ratio of the length of the interval [0.25, 0.5] to the length of the interval
[0.25, 0.75], since X is uniformly distributed.
1 1 3 0.5 − 0.25 0.25 1
P r(X ≤ | ≤X≤ )= = = .
2 4 4 0.75 − 0.25 0.5 2
(b) The second probability is zero since the conditional probability is taken over a
disjoint event from 41 to 13 and from 32 to 1, which does not include 14 .
1 1 2
P r(X ≤ | (X ≤ ) ∪ (X ≥ )) = 0.
4 3 3
Part (b)
Let X1 , X2 , . . . , Xn be independent exponential random variables with parameter 1. We
want to find the expected value of the kth largest of the n random variables.
Solution:
The kth largest of a set of exponential random variables is known as the kth order
statistic. For exponential random variables, the expected value of the kth order statistic
can be found using the sum of the inverses of the parameters of the corresponding
exponential distributions. However, the full solution for this is outside the scope of this
simple template.
Part (c)
Two individuals agree to meet between 12 and 1 for lunch at a sandwich shop. They
agree that each will wait 15 minutes for the other before leaving. We need to determine
the probability they actually meet each other for lunch.
Solution:
Let A and B represent the arrival times of the two individuals, measured in minutes
after 12. Since both arrival times are uniformly distributed over 60 minutes, the joint
distribution of A and B is uniform over the square [0, 60]×[0, 60]. They meet if |A−B| ≤
15. This is a band of width 30 minutes along the line A = B within the square. The
area of this band is 60 × 30 = 1800 square minutes.
The probability they meet is the area of the band divided by the area of the square,
which is 1800 divided by 3600 (since 60 × 60 = 3600).
1800 1
P r(they meet) = = .
3600 2
9
9. Coding Assignment Question: Verify Jensen’s Inequality for the following function:
1
f (x) = , x>0
x
Consider the binomial random variable with parameters p = 14 and n = 20. Update
the code and share the screenshot of the defined function, the defined PMF in Jensen’s
function, and the output.
10