Keuangan Kuantitatif · Buku 18 · Karier

Interviews I: Maths, Probability and Speed

Buku ini belum tersedia dalam Bahasa Indonesia. Edisi: English, Français.

Interviews I: Maths, Probability and Speed · Karier

26Timed Test 3

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

Section A — 6 questions, 40 minutes

Question 26.1

A cereal box holds one of three toys, with probabilities 12\frac12, 13\frac13 and 16\frac16, independently from box to box. On average, how many boxes do you buy to get all three?

Answer

Answer to Question 26.1.

The average is 7.37.3 boxes.

Let TiT_i be the wait for toy ii. The time to get all is max⁡Ti\max T_i, and inclusion–exclusion over minimums gives

Emax⁡=∑i1pi−∑i<j1pi+pj+1p1+p2+p3.\mathbb{E}\max = \sum_i\frac{1}{p_i} - \sum_{i < j}\frac{1}{p_i + p_j} + \frac{1}{p_1 + p_2 + p_3}.

The first sum is 2+3+6=112 + 3 + 6 = 11. The pairs have 56\frac56, 23\frac23 and 12\frac12, which give 1.2+1.5+2=4.71.2 + 1.5 + 2 = 4.7. The last term is 1. So the mean is 11−4.7+1=7.311 - 4.7 + 1 = 7.3.

Sanity check: it must exceed 6, the wait for the rarest toy, and it does so by a little. Equal probabilities would give 5.55.5, so uneven ones cost more.

Classic wrong answer. Using the equal-probability formula 3(1+12+13)3(1 + \frac12 + \frac13), which gives 5.55.5.

Question 26.2

Three fair dice are rolled. Which is more likely, a total of 9 or a total of 10? Give both probabilities.

Answer

Answer to Question 26.2.

A total of 10 is more likely: 27216\frac{27}{216} against 25216\frac{25}{216}.

Both totals have six unordered partitions, which is why they can look equal. But the partitions have different numbers of orderings.

For 9: 126 (6), 135 (6), 144 (3), 225 (3), 234 (6), 333 (1), a total of 25.

For 10: 136 (6), 145 (6), 226 (3), 235 (6), 244 (3), 334 (3), a total of 27.

A check: by the symmetry x→7−xx \to 7 - x, totals 10 and 11 have equal probability, as do 9 and 12. And an enumeration over the 216 outcomes confirms both numbers.

Classic wrong answer. Counting partitions as equally likely, which treats 333 like 126. The outcomes are the 216 ordered triples, and only they are equally likely.

Question 26.3

A source sends four symbols with probabilities 12\frac12, 14\frac14, 18\frac18 and 18\frac18. What is the fewest expected bits per symbol of a prefix code? What is the entropy of the source?

Answer

Answer to Question 26.3.

Both are 1.751.75 bits.

Huffman’s construction merges the two rarest symbols and repeats. It gives code lengths 1, 2, 3 and 3. The expected length is 12⋅1+14⋅2+18⋅3+18⋅3=1.75\frac12 \cdot 1 + \frac14 \cdot 2 + \frac18 \cdot 3 + \frac18 \cdot 3 = 1.75.

The entropy is ∑plog⁡2(1/p)\sum p\log_2(1/p), with the same numbers, since each log⁡2(1/p)\log_2(1/p) is an integer. So the code achieves the theoretical floor exactly.

Compare a fixed-length code, which takes 2 bits. The gain comes from using short words for frequent symbols.

Follow-up. When does the code not reach the entropy? When the probabilities are not powers of 12\frac12. For a source with probabilities 0.90.9 and 0.10.1, the code takes 1 bit a symbol, while the entropy is 0.470.47. Coding blocks of symbols closes this gap.

Question 26.4

XX is uniform on [0,1][0, 1], and given XX, YY is uniform on [0,X][0, X]. What is the probability that Y>12Y > \frac12?

Answer

Answer to Question 26.4.

The probability is 12(1−ln⁡2)≈0.153\frac12(1 - \ln 2) \approx 0.153.

Condition on X=xX = x. For x≤12x \le \frac12, the event is impossible. For x>12x > \frac12, it has chance (x−12)/x=1−12x(x - \frac12)/x = 1 - \frac{1}{2x}. So

P=∫1/21(1−12x)dx=12−12ln⁡2.P = \int_{1/2}^1\left(1 - \frac{1}{2x}\right)dx = \frac12 - \frac12\ln 2.

A second route uses the density of YY, which is −ln⁡y-\ln y on (0,1)(0, 1), found by integrating 1/x1/x from yy to 1. Then P=∫1/21(−ln⁡y) dy=12−12ln⁡2P = \int_{1/2}^1(-\ln y)\,dy = \frac12 - \frac12\ln 2, the same.

The mean of YY is 14\frac14, so a chance of 0.150.15 to exceed 12\frac12 is reasonable.

Classic wrong answer. Using XX’s mean, 12\frac12, as if YY were uniform on [0,12][0, \frac12], which gives 0. A value cannot replace a distribution here.

Question 26.5

Two players take turns rolling a die, and A goes first. A wins by rolling a 6. B wins by rolling a 5 or a 6. What is the probability that A wins?

Answer

Answer to Question 26.5.

A wins with probability 38\frac38.

Each full round, A wins with chance 16\frac16. If A fails, B wins with chance 13\frac13. So the game continues to another round with chance 56⋅23=59\frac56 \cdot \frac23 = \frac59.

Let aa be A’s chance. Then a=16+59aa = \frac16 + \frac59a, which gives a=16⋅94=38a = \frac16 \cdot \frac94 = \frac38.

A check: B’s chance is 56⋅13/(49)=58\frac56 \cdot \frac13/(\frac49) = \frac58, and the two add to 1. So going first is not enough to offset a target that is twice as easy. With equal targets of a 6, A would have 611\frac{6}{11}.

Classic wrong answer. Adding up only A’s first roll, or giving 13\frac13 by comparing the two chances directly, 16/(16+13)\frac16/(\frac16 + \frac13). That ignores who rolls first.

Question 26.6

Three vertices of a regular hexagon are chosen at random. How likely are they to form a right triangle? What about an equilateral triangle?

Answer

Answer to Question 26.6.

A right triangle has probability 35\frac35, and an equilateral one has probability 110\frac{1}{10}.

There are (63)=20\binom63 = 20 triangles. The hexagon’s vertices lie on a circle, so a triangle has a right angle exactly when two of its vertices form a diameter. There are 3 diameters. Each can be combined with any of the 4 other vertices, which gives 12 triangles, all different, since a triangle cannot contain two diameters.

So the right triangles have 1220\frac{12}{20}. The equilateral triangles are the two formed by alternate vertices, so 220\frac{2}{20}. The remaining 6 are isosceles with an obtuse angle: three neighbouring vertices. An enumeration confirms the counts.

Classic wrong answer. Trying to compute angles for each case. The diameter criterion gives the count at once.

Section B — 6 questions, 60 minutes

Question 26.7

A permutation of 1,…,81, \dots, 8 is chosen at random. How likely is it that the element 8 lies in a cycle of length exactly 3? What is the expected number of cycles?

Answer

Answer to Question 26.7.

The probability is 18\frac18, and the expected number of cycles is H8=761280≈2.72H_8 = \frac{761}{280} \approx 2.72.

Follow the cycle from 8. It closes at the first step with chance 18\frac18, the value π(8)=8\pi(8) = 8. Otherwise it continues to another element, and closes at the next step with chance 17\frac17, and so on. The chance that it has length 3 is 78⋅67⋅16=18\frac78 \cdot \frac67 \cdot \frac16 = \frac18. All lengths from 1 to 8 are equally likely, by the same cancellation.

For the number of cycles, use that each element ii in a cycle of length LiL_i contributes 1/Li1/L_i, with total 1 per cycle. So the count is ∑i1/Li\sum_i1/L_i, and its mean is 8⋅18(1+12+⋯+18)=H88 \cdot \frac18(1 + \frac12 + \dots + \frac18) = H_8. Counting by brute force over all permutations gives the same.

Follow-up. What is the mean length of the cycle holding a given element? (n+1)/2=4.5(n + 1)/2 = 4.5, the mean of the uniform on 1 to 8. Note that this is larger than the average cycle length, 8/H8=2.948/H_8 = 2.94, an inspection effect.

Question 26.8

A disease affects 1% of people, independently. You pool the blood of 10 people and test the pool once. If it is positive, you test all 10 individually. What is the expected number of tests per person?

Answer

Answer to Question 26.8.

About 0.1960.196 tests per person, a saving of about 80%.

The pool costs one test, or 110\frac{1}{10} per person. With chance 1−0.99101 - 0.99^{10}, the pool is positive, and each person takes one more test. So the mean per person is

110+1−0.9910=0.1+0.0956=0.1956.\frac{1}{10} + 1 - 0.99^{10} = 0.1 + 0.0956 = 0.1956.

For the value, 0.9910≈e−0.1≈0.9040.99^{10} \approx e^{-0.1} \approx 0.904.

The best pool size balances the two terms: for f(k)=1/k+1−0.99kf(k) = 1/k + 1 - 0.99^k, the minimum is near k≈1/p=10k \approx 1/\sqrt{p} = 10. An exact search shows that pools of 10 and 11 are almost the same. So 10 is a good design.

Follow-up. If the rate rises to 30%, is pooling still useful? Barely. A pool of 2 costs 1.011.01 per person, the best pool, of 3, costs 0.990.99, and larger pools cost more. So it no longer pays to bother.

Question 26.9

You keep rolling a fair die and keep a running total. What is the probability that the running total ever equals exactly 6? What is the long-run chance of hitting a large number nn?

Answer

Answer to Question 26.9.

The probability is 16(76)5≈0.360\frac16(\frac76)^5 \approx 0.360, and for large nn it tends to 27\frac27.

Let pnp_n be the chance of hitting nn, with p0=1p_0 = 1. Conditioning on the last roll, for n≤6n \le 6,

pn=16(pn−1+⋯+p0).p_n = \frac16(p_{n - 1} + \dots + p_0).

So p1=16p_1 = \frac16, and pn+1=pn+16pn=76pnp_{n + 1} = p_n + \frac16p_n = \frac76p_n for n≥1n \ge 1 up to 5. Thus p6=16(76)5p_6 = \frac16(\frac76)^5. An exact recursion in fractions gives this number.

For large nn, renewal theory says that hits occur at a rate of one per mean step, and the mean step is 3.53.5. So pn→1/3.5=27=0.286p_n \to 1/3.5 = \frac27 = 0.286.

Note that p6p_6 is the largest of the pnp_n: from 6 onwards, the bound on the number of earlier terms in the recursion takes effect.

Classic wrong answer. Enumerating the compositions of 6 and weighting each by (16)k(\frac16)^k. That works, but it is the slow form of the same answer.

Question 26.10

A stick of length 1 is broken at a uniform random point, and the two pieces become the sides of a rectangle. What is the average area of the rectangle? How likely is the area to exceed 316\frac{3}{16}?

Answer

Answer to Question 26.10.

The average area is 16\frac16, and the area exceeds 316\frac{3}{16} with chance 12\frac12.

With the break at xx, uniform on [0,1][0, 1], the area is x(1−x)x(1 - x), whose mean is 12−13=16\frac12 - \frac13 = \frac16. The area exceeds 316\frac{3}{16} when (x−14)(x−34)<0(x - \frac14)(x - \frac34) < 0, that is when xx lies between 14\frac14 and 34\frac34, and this has chance 12\frac12.

A check: the shorter piece SS has mean 14\frac14 and the longer LL has mean 34\frac34, with product 316\frac{3}{16}. But L=1−SL = 1 - S, so their covariance is −Var⁡(S)=−148-\operatorname{Var}(S) = -\frac{1}{48}, and 316−148=16\frac{3}{16} - \frac{1}{48} = \frac16.

Classic wrong answer. Giving 316\frac{3}{16}, the product of the mean pieces, or 14\frac14, the area at the mean break. The first ignores that the pieces are negatively correlated, and the second is the largest area possible, reached by a single break point.

Why it matters. The mean of a product is the product of the means only without correlation. The average of price times volume is not the average price times the average volume.

Question 26.11

An at-the-money three-month call on a stock at 100 with 16% volatility is worth about 0.4SσT0.4S\sigma\sqrt{T}, with zero rates. Estimate the price of the straddle. What daily move makes a delta-hedged holder break even, using 252 days?

Answer

Answer to Question 26.11.

The straddle costs about 6.46.4, and the daily break-even move is about 1, or 1%.

The call is worth 0.4×100×0.16×0.5=3.20.4 \times 100 \times 0.16 \times 0.5 = 3.2. At the money with zero rates, put and call have the same value, by parity. So the straddle costs 6.46.4.

The factor comes from 2ϕ(0)12≈0.42\phi(0)\frac12 \approx 0.4: the call is S(2Φ(12σT)−1)S(2\Phi(\frac12\sigma\sqrt{T}) - 1), and it is linear in a small argument.

A delta-hedged option earns 12ΓS2(r2−σ2Δt)\frac12\Gamma S^2(r^2 - \sigma^2\Delta t) per step, so it breaks even when the daily return equals σΔt=16%/252=1.01%\sigma\sqrt{\Delta t} = 16\%/\sqrt{252} = 1.01\%. That is the rule of 16: annual vol over 16 is the daily move.

Classic wrong answer. Comparing the ±6.4\pm 6.4 break-even at expiry with daily moves. A hedged holder’s result depends on the sum of squared moves, not on where the stock ends.

Follow-up. What does the straddle cost at one year? 6.4×2=12.86.4 \times 2 = 12.8, since the time scale doubles the root.

Question 26.12

A random permutation of 1,…,101, \dots, 10 is written in a line. A position is a local maximum if its value exceeds those of its neighbours, and each end has only one neighbour. How many local maxima are there on average?

Answer

Answer to Question 26.12.

The average is 113\frac{11}{3}.

Use indicators. An interior position, with two neighbours, has the largest of three random distinct values with chance 13\frac13. An end position, with one neighbour, has chance 12\frac12.

There are 8 interior positions and 2 ends, so the mean is 83+1=113\frac83 + 1 = \frac{11}{3}. Brute force for small nn follows the general formula (n+1)/3(n + 1)/3.

The result is about one in three positions, which is the rate at which a random series makes a peak. So if a chart seems to have fewer turning points than this, the series has a trend or a memory.

Follow-up. What is the count of runs of ascents, for n=10n = 10? The number of ascents has mean 4.54.5, and maximal ascending runs number one more than the descents, so 5.55.5 on average. These are the same indicators with pairs in place of triples.