---
title: "Timed Test 5"
book: "Interviews I: Maths, Probability and Speed"
subject: quant
language: en
chapter: 28
exercises: 0
source: https://one-course.com/books/quant/18/en/chapter/28-timed-test-5
license: CC-BY-NC-SA-4.0
credit: "One Quant Book, One Course (one-course.com)"
---

# Chapter 28 — Timed Test 5

Take it in one sitting, without notes or a calculator.

## Section A — 6 questions, 40 minutes

**Question 28.1.**

Events arrive as a Poisson process with rate 2 per hour. What are the mean and variance of the time of the third event? What is the probability that the third event arrives after one hour?

**Answer to Question 28.1.**

The mean is $1.5$ hours, the variance is $0.75$, and the probability is $5e^{-2} \approx 0.677$.

The gaps are independent exponentials with mean $\frac12$ and variance $\frac14$. The third arrival is the sum of three of them, a Gamma variable. So the mean is $\frac32$ and the variance is $\frac34$.

The third arrival comes after one hour exactly when at most 2 events occur in that hour. The count is Poisson with mean 2, so

$$
P = e^{-2}\left(1 + 2 + \frac{2^2}{2}\right) = 5e^{-2}.
$$

With $e^{-2} \approx 0.135$, this gives $0.677$. The mean of $1.5$ makes this plausible. A simulation agrees.

**Classic wrong answer.** Using a normal approximation with 3 terms, which gives about $0.72$. The Gamma is skewed, and the exact route takes one line.

**Question 28.2.**

You flip a fair coin until the first head, and let $N$ be the number of flips. Then you roll $N$ fair dice and add them up. Find the mean and the variance of the sum.

**Answer to Question 28.2.**

The mean is 7, and the variance is $30\frac13$.

$N$ is geometric with mean 2 and variance 2. A die has mean $3.5$ and variance $\frac{35}{12}$.

The law of total expectation gives $2 \times 3.5 = 7$.

The law of total variance gives

$$
\operatorname{Var}S = \mathbb{E}N\operatorname{Var}X + \operatorname{Var}N(\mathbb{E}X)^2 = 2 \cdot \frac{35}{12} + 2 \cdot 12.25 = 5.83 + 24.5 = 30.33.
$$

Most of the variance comes from not knowing how many dice there are. A simulation returns $7.0$ and $30.3$.

**Classic wrong answer.** Using $\mathbb{E}N\operatorname{Var}X$ alone, or $\operatorname{Var}(N)\operatorname{Var}(X)$. The second term has the squared mean of $X$, not its variance.

**Question 28.3.**

A coin has an unknown probability of heads, with a uniform prior on $[0, 1]$. You see 3 heads in 4 flips. What is the posterior mean? What is the probability that the next two flips are both heads?

**Answer to Question 28.3.**

The posterior mean is $\frac23$, and the probability of two heads is $\frac{10}{21}$.

The uniform prior is Beta$(1, 1)$, so after 3 heads and 1 tail the posterior is Beta$(4, 2)$. Its mean is $\frac46$.

The next two flips use the posterior of the posterior. The first head has chance $\frac46$. After it, the distribution is Beta$(5, 2)$, so the next head has chance $\frac57$. The product is $\frac{20}{42} = \frac{10}{21} = 0.476$.

Note that this exceeds $(\frac23)^2 = 0.444$. Uncertainty in the coin’s bias makes the two flips positively correlated. A numerical integral of $p^2$ over the posterior gives the same value.

**Classic wrong answer.** Squaring the posterior mean, which assumes that the bias is now known exactly. The difference is the posterior variance of $p$.

**Question 28.4.**

Five red and five blue balls are lined up in a random order. A run is a maximal block of one colour. What is the expected number of runs? What is the probability of exactly two runs?

**Answer to Question 28.4.**

The expected number is 6, and the probability of exactly two runs is $\frac{1}{126}$.

The number of runs is 1 plus the number of neighbouring pairs of different colours. Take any one of the 9 neighbouring pairs. The chance that it has different colours is $\frac{5}{10}\cdot\frac{5}{9} \times 2 = \frac59$. So the mean is $1 + 9 \cdot \frac59 = 6$.

Exactly two runs means all the reds and then all the blues, or the reverse. That is 2 orders out of $\binom{10}{5} = 252$, so $\frac{1}{126}$.

An enumeration of all 252 orders confirms both. It is more than the $5.5$ runs of 10 independent fair flips, since drawing without replacement makes a change of colour a little more likely.

**Classic wrong answer.** Using $\frac12$ for each pair, as for independent flips, which gives $5.5$. Having drawn a red, only 4 of the remaining 9 balls are red.

**Question 28.5.**

Three fair dice are rolled. What is the probability that the product of the three numbers is divisible by 6?

**Answer to Question 28.5.**

The probability is $\frac{133}{216} \approx 0.616$.

The product is divisible by 6 when it has a factor of 2 and a factor of 3. Use the complement and inclusion–exclusion.

No factor of 2 means all dice odd: $(\frac12)^3 = \frac{27}{216}$. No factor of 3 means no die showing 3 or 6: $(\frac23)^3 = \frac{64}{216}$. Neither factor means all dice in $\{1, 5\}$: $(\frac13)^3 = \frac{8}{216}$.

So the failure chance is $\frac{27 + 64 - 8}{216} = \frac{83}{216}$, and the answer is $\frac{133}{216}$. An enumeration confirms the count of 133.

**Classic wrong answer.** Multiplying the chances of having a factor of 2 and of having a factor of 3, as if independent. Both depend on the same dice: a 6 supplies both.

**Question 28.6.**

$X$ and $Y$ are independent standard normals. What is the chance that the point $(X, Y)$ lies within radius 1 of the origin? What radius holds exactly half the probability?

**Answer to Question 28.6.**

The chance is $1 - e^{-1/2} \approx 0.393$, and the radius is $\sqrt{2\ln 2} \approx 1.18$.

$R^2 = X^2 + Y^2$ has an exponential law with mean 2. In polar form, the density is $\frac{1}{2\pi}e^{-r^2/2}r\,dr\,d\theta$, and so $P(R > r) = e^{-r^2/2}$.

At $r = 1$: $1 - e^{-1/2} = 0.393$. For the median: $e^{-r^2/2} = \frac12$ gives $r = \sqrt{2\ln 2}$.

Compare one dimension: a standard normal is inside $\pm 1$ with chance $0.683$. Going to two dimensions drops this to $0.393$. In a high dimension, the mass moves further out, a fact that matters for distance-based methods. A simulation agrees.

**Follow-up.** *What is the mean radius?* $\sqrt{\pi/2} = 1.25$, the mean of a Rayleigh variable.

## Section B — 6 questions, 60 minutes

**Question 28.7.**

An election between A and B ends with 7 votes for A and 3 for B, counted in random order. What is the probability that A is strictly ahead throughout the count?

**Answer to Question 28.7.**

The probability is $\frac{7 - 3}{7 + 3} = \frac25$.

This is the ballot theorem. Count the bad orders. If the first vote is for B, the order is bad, and there are $\binom92$ such orders. If the first vote is for A and the count is tied at some point, reflect the part before the first tie: this swaps A and B votes and gives a sequence starting with B. So that second group of bad orders matches the first group one-to-one.

The bad orders number $2\binom92 = 72$ out of $\binom{10}{3} = 120$. So the good ones have $\frac{48}{120} = \frac25$. An enumeration confirms this.

In the limits, a 3–3 count gives 0, as a tie at the end is forced, and a 7–0 count gives 1.

**Classic wrong answer.** Using the chance that A’s lead is positive at the end, which is 1 here, or simply A’s share of the votes, $\frac{7}{10}$.

**Question 28.8.**

In a random graph on 10 vertices, each edge is present independently with probability $\frac12$. Find the mean and the variance of the number of triangles.

**Answer to Question 28.8.**

The mean is 15, and the variance is $52.5$.

There are $\binom{10}{3} = 120$ possible triangles, each present with chance $\frac18$. So the mean is 15.

Each indicator has variance $\frac18 \cdot \frac78 = \frac{7}{64}$, for a total of $120 \times \frac{7}{64} = 13.125$.

Covariances: two triangles with no common edge are independent. Two sharing exactly one edge have five edges in total, so

$$
\operatorname{Cov} = 2^{-5} - 2^{-6} = \frac{1}{64}.
$$

Each triangle shares an edge with $3 \times 7 = 21$ others, one for each edge and each of the 7 other vertices. So there are $120 \times 21$ ordered pairs, adding $\frac{2520}{64} = 39.375$.

The total is $13.125 + 39.375 = 52.5$. A simulation gives $15.0$ and about $52.5$. Note that the correlation adds exactly three times the independent variance.

**Classic wrong answer.** Stopping at $13.125$, which treats triangles as independent. Sharing an edge is a positive dependence, which makes the count much more variable.

**Question 28.9.**

Using $\log_{10}2 = 0.30103$, how many decimal digits does $2^{1000}$ have, and what is its leading digit?

**Answer to Question 28.9.**

It has 302 digits, and the leading digit is 1.

$\log_{10}2^{1000} = 301.03$. A number with base-10 logarithm between 301 and 302 has 302 digits.

The fractional part gives the leading digits: $10^{0.03}$. Since $\ln 10 \approx 2.3$, $10^{0.03} = e^{0.069} \approx 1.07$. So the number begins with 1.07, and the first digit is 1.

An exact computation with big integers gives 302 digits, starting 1071. Note that a small error in the logarithm’s fifth digit, multiplied by 1000, moves the fractional part by a hundredth, and that is why the digits given in the question are enough for the first digit and just about for the second.

**Follow-up.** *How often is the first digit of $2^n$ equal to 1, in the long run?* $\log_{10}2 = 30.1\%$. The fractional parts of $n\log_{10}2$ are equidistributed, which gives Benford’s law for this sequence.

**Question 28.10.**

Bus line A arrives every 10 minutes and line B every 15 minutes, each on a fixed timetable, with independent uniform phases. You arrive at a random time and take the first bus. What is your expected wait?

**Answer to Question 28.10.**

The expected wait is $\frac{35}{9} \approx 3.89$ minutes.

The waits are $U \sim \text{uniform}(0, 10)$ and $V \sim \text{uniform}(0, 15)$. Then

$$
\mathbb{E}\min(U, V) = \int_0^{10}\left(1 - \frac{t}{10}\right)\left(1 - \frac{t}{15}\right)dt.
$$

Expanding the integrand as $1 - \frac{t}{6} + \frac{t^2}{150}$, the integral is $10 - \frac{100}{12} + \frac{1000}{450} = 10 - 8.33 + 2.22 = 3.89$. A simulation returns $3.89$.

Checks: the wait must be below 5, the mean wait for A alone. The rule for Poisson lines with the same frequencies gives $1/(\frac{1}{10} + \frac{1}{15}) = 6$, which is much longer: regular buses are better than random ones.

**Classic wrong answer.** Giving 3, by combining the two mean waits as parallel rates of $\frac15 + \frac{1}{7.5}$. The waits are uniform, not exponential.

**Question 28.11.**

A game show has 5 doors, one with a prize. You choose a door. The host, who knows where the prize is, opens one other door with no prize behind it, and offers a switch. If you switch at random to one of the three remaining closed doors, what is your chance of winning?

**Answer to Question 28.11.**

Switching wins with probability $\frac{4}{15}$, against $\frac15$ for staying.

Your door has the prize with chance $\frac15$, and the host’s action does not change this: the host can always open a goat door. So the other four doors hold the prize with chance $\frac45$, and the host has shown that one of them does not. That $\frac45$ is now spread across 3 doors.

So each closed door you did not choose has chance $\frac{4}{15}$. The sum checks: $\frac15 + 3 \times \frac{4}{15} = 1$.

A simulation with a random host gives $0.267$. Switching is better by a third. With $n$ doors and one opened, the chance is $(n - 1)/(n(n - 2))$. For $n = 3$, this is $\frac23$, the well-known case.

**Classic wrong answer.** Saying $\frac14$, with four closed doors treated as equally likely. Your own door is not like the others: the host was never allowed to open it, so the host’s choice says nothing about it.

**Question 28.12.**

$X$ is binomial with 100 trials and success probability $\frac12$. Bound $P(X \ge 70)$ by Hoeffding’s inequality $\exp(-2t^2/n)$, with $t$ the excess over the mean. Compare the bound with Chebyshev’s inequality and the normal approximation.

**Answer to Question 28.12.**

Hoeffding gives $e^{-8} \approx 3.4 \times 10^{-4}$, Chebyshev gives $0.0625$ for the two-sided event, and the normal approximation gives about $5 \times 10^{-5}$.

Here $t = 20$ and $n = 100$, so $2t^2/n = 8$. The bound is $e^{-8}$.

Chebyshev uses the variance of 25: $P(|X - 50| \ge 20) \le 25/400 = 0.0625$. One tail is at most half of this if symmetry is used, $0.031$.

The normal approximation with continuity correction uses $z = 19.5/5 = 3.9$, with tail $4.8 \times 10^{-5}$. The exact binomial tail is $3.9 \times 10^{-5}$.

So Chebyshev is off by a thousandfold, and Hoeffding by a factor of about 9, which is good for a bound with no assumption beyond boundedness. Each is valid: they only trade tightness for generality.

**Classic wrong answer.** Treating a bound as an estimate. An upper bound says what cannot happen, and it can be far from the true value.
