Finance quantitative · Book 18 · Carrières

Interviews I: Maths, Probability and Speed

Interviews I: Maths, Probability and Speed · Carrières

12Continuous and Geometric Probability

Turning a question about uniform or normal variables into a region whose area you can see. The early questions are pictures on a square; the later ones use symmetry on circles and spheres, the angle of a pair of normals, and the structure of spacings.

Question 12.1 ★ QR, QT, Trader, Analyst • any • junior

A stick of length 1 is cut at a uniform random point. What is the average length of the longer piece? What is the average ratio of the shorter piece to the longer one?

Answer

Answer to Question 12.1.

The longer piece averages 3/43/4. The ratio of shorter to longer averages 2ln⁡2−1≈0.3862\ln 2 - 1 \approx 0.386.

The longer piece is uniform on [12,1][\tfrac12, 1], with density 2, so its mean is 3/43/4. With length ℓ\ell for the longer piece, the ratio is (1−ℓ)/ℓ(1 - \ell)/\ell, and

E[1−ℓℓ]=∫1/212(1ℓ−1)dℓ=2ln⁡2−1.E\Bigl[\frac{1 - \ell}{\ell}\Bigr] = \int_{1/2}^{1} 2\Bigl(\frac1\ell - 1\Bigr) d\ell = 2\ln 2 - 1.

Classic wrong answer. Dividing the two means, (1/4)/(3/4)=1/3(1/4)/(3/4) = 1/3. The mean of a ratio is not the ratio of the means, because a ratio changes more for a short denominator.

Question 12.2 ★ QR, QT, Trader • any • junior

XX and YY are independent and uniform on [0,1][0, 1]. What is the probability that XY<1/2XY < 1/2?

Answer

Answer to Question 12.2.

The probability is 12+12ln⁡2≈0.847\tfrac12 + \tfrac12 \ln 2 \approx 0.847.

Draw the unit square and the curve y=1/(2x)y = 1/(2x). For x≤12x \le \tfrac12, the curve lies above the square, so every yy qualifies, which contributes 12\tfrac12. For x>12x > \tfrac12, the allowed height is 1/(2x)1/(2x), which contributes

∫1/21dx2x=12ln⁡2.\int_{1/2}^{1} \frac{dx}{2x} = \tfrac12 \ln 2.

Classic wrong answer. Answering 1/21/2, by treating XYXY as if it were uniform. The product is skewed low: its median is only about 0.190.19, so 1/21/2 is well up in its upper tail.

Question 12.3 ★ QR, QT, Trader, DS • any • junior

XX and YY are independent and uniform on [0,1][0, 1]. What are the mean and variance of ∣X−Y∣|X - Y|?

Answer

Answer to Question 12.3.

The mean is 1/31/3 and the variance is 1/181/18.

The event ∣X−Y∣>t|X - Y| > t is two corner triangles of total area (1−t)2(1 - t)^2. So the density of D=∣X−Y∣D = |X - Y| is 2(1−t)2(1 - t) on [0,1][0, 1], and E[D]=∫012t(1−t) dt=1/3E[D] = \int_0^1 2t(1 - t)\,dt = 1/3.

For the variance, E[D2]=E[(X−Y)2]=2 Var(X)=1/6E[D^2] = E[(X - Y)^2] = 2\,\mathrm{Var}(X) = 1/6, so the variance is 1/6−1/9=1/181/6 - 1/9 = 1/18.

Follow-up. And for two independent standard normals? X−YX - Y has variance 2, so E∣X−Y∣=22/π=2/πE|X - Y| = \sqrt{2}\sqrt{2/\pi} = 2/\sqrt{\pi}.

Question 12.4 ★ QR, QT, Trader, Analyst • any • junior

Two people agree to meet at a cafe between noon and 1 p.m. Each arrives at an independent uniform time in that hour and waits 15 minutes for the other before leaving. What is the probability that they meet?

Answer

Answer to Question 12.4.

The probability is 7/167/16.

The pair of arrival times is uniform on a square of side 1 hour. They meet when ∣X−Y∣≤14|X - Y| \le \tfrac14, a band around the diagonal. Outside the band are two corner triangles, each with legs 34\tfrac34, which together have area (34)2=9/16(\tfrac34)^2 = 9/16.

If they each wait the whole hour, the formula gives 1, and if neither waits at all, it gives 0, which is a quick check.

Classic wrong answer. One half, by doubling a 15-minute window to 30 minutes out of 60. The window is cut off at the ends of the hour, for someone who arrives near noon or 1 p.m.

Question 12.5 ★ QR, DS, QD, QT • any • junior

A point is uniform in a unit cube in dd dimensions. What is the probability that it lies within 0.050.05 of the boundary, for d=1d = 1, 10 and 100? What is the probability that it lies in the largest ball that fits in the cube, for d=3d = 3 and for d=10d = 10? What does this say about high-dimensional data?

Answer

Answer to Question 12.5.

Within 0.050.05 of the boundary: 0.10.1, about 0.6510.651 and about 0.999970.99997. In the ball: about 0.5240.524 for d=3d = 3, and about 0.00250.0025 for d=10d = 10.

The point is at least 0.050.05 away from the boundary only if each coordinate lies in [0.05,0.95][0.05, 0.95], a chance of 0.90.9 each, so the chance is 0.9d0.9^d. The ball of diameter 1 has volume π/6\pi/6 for d=3d = 3, and for d=10d = 10 it is π5/(5!⋅210)\pi^5/(5! \cdot 2^{10}).

So in high dimensions, nearly all of a cube is at its corners and edges, and almost none of it is near the middle. Data points are far from one another and also far from any centre: the typical distance from the centre of the unit cube grows like d/12\sqrt{d/12}, about 2.92.9 at d=100d = 100.

Why it matters. This is why nearest-neighbour methods and density estimates fail with many features: with 100 features there is no such thing as a “nearby” point, and every point looks like an outlier.

Question 12.6 ★★ QR, QT, Trader, Analyst • any • junior

A stick of length 1 is broken at two independent uniform points. What is the probability that the three pieces form a triangle? If instead you break it once at a uniform point, and then break the longer piece at a uniform point, what is it? And if you break a piece picked at random with equal chance?

Answer

Answer to Question 12.6.

Breaking twice gives 1/41/4. Breaking the longer piece gives 2ln⁡2−1≈0.3862\ln 2 - 1 \approx 0.386, and breaking a random piece gives half of that, about 0.1930.193.

Three pieces form a triangle exactly when each is below 12\tfrac12, since the longest must be less than the sum of the other two, which is 11 minus itself. For two cuts at u<vu < v, this needs u<12u < \tfrac12, v−u<12v - u < \tfrac12 and v>12v > \tfrac12. In the unit square that is the shaded area in Figure 12.1, which has area 1/41/4.

For the longer piece, let its length be ℓ\ell. The shorter piece is already below 12\tfrac12. A cut at aa leaves two pieces below 12\tfrac12 when ℓ−12<a<12\ell - \tfrac12 < a < \tfrac12, which is a fraction (1−ℓ)/ℓ(1 - \ell)/\ell of the piece. Averaging over ℓ\ell gives the same integral as the ratio of pieces: 2ln⁡2−12\ln 2 - 1.

Choosing a piece at random picks the longer one half the time. Breaking the shorter can never work, because the untouched longer piece is already above 12\tfrac12. So the chance is half of the above.

Two independent cuts on a stick. The pieces form a triangle in the two shaded triangles, a quarter of the square.
Figure 12.1. Two independent cuts on a stick. The pieces form a triangle in the two shaded triangles, a quarter of the square.

Classic wrong answer. Treating the second problem as the same as the first. Choosing the longer piece makes a triangle more likely, because it removes the worst case.

Question 12.7 ★★ QR, QT, Trader • any • junior

XX, YY and ZZ are independent and uniform on [0,1][0, 1]. What is the probability that three sticks of those lengths can form a triangle?

Answer

Answer to Question 12.7.

The probability is 1/21/2.

They fail to form a triangle exactly when one is longer than the sum of the other two. No two of these three events can occur together, since only the longest stick can break the rule. Each event, such as Z>X+YZ > X + Y, has probability 1/61/6: it is the corner of the unit cube at (0,0,1)(0, 0, 1), a pyramid with volume 13⋅12⋅1\tfrac13 \cdot \tfrac12 \cdot 1. So the probability of failure is 3⋅16=123 \cdot \tfrac16 = \tfrac12.

Classic wrong answer. Using 1/41/4, by recalling the broken stick. In that problem the three lengths must add up to 1, and they are not independent. Here each can be anything, and the chance of a triangle is larger.

Follow-up. With four sticks and a four-sided figure? The longest must be less than the sum of the other three. Each failure event has probability 1/241/24, so the answer is 1−4/24=5/61 - 4/24 = 5/6.

Question 12.8 ★★ QR, QT, Trader, QD • any • junior

A floor has parallel lines one unit apart. You drop a needle of length 1 at a random position and angle. What is the probability that it crosses a line? If the needle has length 3, how many crossings does it make on average? Find the second without doing any integral for that length.

Answer

Answer to Question 12.8.

A needle of length 1 crosses with probability 2/π≈0.6372/\pi \approx 0.637. A needle of length 3 makes 6/π≈1.916/\pi \approx 1.91 crossings on average.

For the first, let θ\theta be the angle to the lines, uniform on [0,π)[0, \pi). The needle’s extent across the lines is sin⁡θ\sin\theta, and for that angle the crossing probability is sin⁡θ\sin\theta, because the needle’s position relative to the lines is uniform. Its average is 2/π2/\pi.

For the second, use linearity. A needle of length 3 is three needles of length 1 end to end. Each has the same mean number of crossings, whatever the joins, so the mean is 3⋅2/π3 \cdot 2/\pi. In fact this holds for any shape: the mean crossing number is 2L/πd2L/\pi d, with LL the length and dd the spacing. A circle of diameter 1 has L=πL = \pi and crosses twice for sure, and the formula gives 2, which is a neat proof of the constant.

Classic wrong answer. Trying to find P(at least one)P(\text{at least one}) for the long needle. That needs an integral over angles, while the mean does not. The question asks for the mean because linearity makes it almost free.

Question 12.9 ★★ QR, QT, Trader • any • junior

You place nn points independently and uniformly on a circle. What is the probability that they all lie in some semicircle? Give the answer for n=3n = 3 and n=5n = 5. What does it say about whether a triangle on three points contains the centre?

Answer

Answer to Question 12.9.

The probability is n/2n−1n/2^{n - 1}, so 3/43/4 for n=3n = 3 and 5/165/16 for n=5n = 5. A triangle on three points contains the centre with probability 1/41/4.

If the points lie in a semicircle, then going clockwise there is a unique first point of the arc. The events “point ii is first” are disjoint. Given that point ii is first, all the others must fall in the half-circle clockwise from it, which has probability 2−(n−1)2^{-(n - 1)}. There are nn such events, so the total is n/2n−1n/2^{n - 1}.

A triangle contains the centre exactly when its three corners do not fit in a semicircle, so that is 1−3/4=1/41 - 3/4 = 1/4.

Classic wrong answer. Fixing the first point, and asking that the others lie in the half-circle after it, which gives 2−(n−1)2^{-(n - 1)}. That forgets that any of the nn points could be the start of the arc.

Follow-up. And for n=2n = 2? The formula gives 1, which is right: two points always lie in a semicircle.

Question 12.10 ★★ QR, QT, Trader • any • junior

You place 4 independent uniform points on a circle, join the first two with a chord and the last two with another. What is the probability that the chords cross? If 20 such points are joined in 10 fixed pairs, how many crossings are there on average?

Answer

Answer to Question 12.10.

Two chords cross with probability 1/31/3, and 10 chords have 15 crossings on average.

Label the four points in order around the circle. Whatever their positions, three pairings are possible, each equally likely: the first point pairs with its neighbour clockwise, with the one opposite, or with its neighbour anticlockwise. Only the opposite pairing crosses, so the chance is 1/31/3.

There are (102)=45\binom{10}{2} = 45 pairs of chords, and each pair is a setup of four independent random points. So by linearity, whatever the dependence between pairs, the mean number of crossings is 45⋅13=1545 \cdot \tfrac13 = 15.

Classic wrong answer. Trying a calculation over the lengths of arcs. Only the relative order of the four points matters, which is why the answer has no integral.

Follow-up. Are the crossings independent? No, but linearity does not need it. A question about the variance would need the correlations, and then the work starts.

Question 12.11 ★★ QR, QT, DS • any • junior

A chord of a unit circle is chosen “at random”. How likely is it to be longer than the side of the equilateral triangle inscribed in that circle? Compute it for three natural ways of choosing the chord, and say what the differing answers show.

Answer

Answer to Question 12.11.

The answers are 1/31/3, 1/21/2 and 1/41/4, depending on the method. This is Bertrand’s paradox.

The side of the inscribed equilateral triangle has length 3\sqrt{3}, and such a chord lies at a distance of 12\tfrac12 from the centre. So the chord is longer exactly when it passes within 12\tfrac12 of the centre.

Random endpoints: fix one end. The other must lie on the third of the circle opposite to it: 1/31/3.

Random distance along a radius: the distance from the centre is uniform on [0,1][0, 1], so being below 12\tfrac12 has chance 1/21/2.

Random midpoint in the disc: the midpoint must lie in the disc of radius 12\tfrac12, which has a quarter of the area: 1/41/4.

All three are correct answers to different questions. “At random” does not define a distribution on an infinite set. The first thing to do when a question says this is to ask what mechanism produced the object.

Why it matters. The same issue arises whenever you assign a flat prior. Flat in volatility and flat in variance are different beliefs, and which one you take can change a result. State the parameterisation before you state the answer.

Question 12.12 ★★ QR, QT, Trader, DS • any • junior

XX and YY are independent standard normal variables. What is the probability that X>0X > 0 and Y>3 XY > \sqrt{3}\,X? What is the probability that X+Y>0X + Y > 0, given that X>0X > 0?

Answer

Answer to Question 12.12.

The first probability is 1/121/12, and the second is 3/43/4.

Two independent standard normals have a density that depends only on the distance from the origin, so the direction of (X,Y)(X, Y) is uniform. Each event becomes a sector, and its probability is its angle over the whole.

For X>0X > 0 and Y>3XY > \sqrt{3}X: the line y=3xy = \sqrt{3}x is at 6060 degrees, and the region runs from there to the vertical axis, a sector of 3030 degrees. So the chance is 30/360=1/1230/360 = 1/12.

For X+Y>0X + Y > 0 given X>0X > 0: the half-plane x>0x > 0 is 180180 degrees. The half-plane x+y>0x + y > 0 overlaps it in the sector from −45-45 to 9090 degrees, which is 135135 degrees. So the chance is 135/180=3/4135/180 = 3/4.

Classic wrong answer. Conditioning on XX and integrating a normal tail. This works but it is slow, and it misses what makes normals special.

Follow-up. In correlation terms? X+YX + Y and XX have a correlation of 1/21/\sqrt{2}, and the sign-agreement formula 12+arcsin⁡(ρ)/π\tfrac12 + \arcsin(\rho)/\pi gives the same 3/43/4.

Question 12.13 ★★ QR, QT, DS, Risk • any • junior

XX and YY are independent standard normal variables. What is the probability that X2+Y2>4X^2 + Y^2 > 4? What are the mean and variance of the larger of XX and YY?

Answer

Answer to Question 12.13.

P(X2+Y2>4)=e−2≈0.135P(X^2 + Y^2 > 4) = e^{-2} \approx 0.135. The larger has mean 1/π≈0.5641/\sqrt{\pi} \approx 0.564 and variance 1−1/π≈0.6821 - 1/\pi \approx 0.682.

In polar coordinates, R2=X2+Y2R^2 = X^2 + Y^2 is exponential with mean 2, so the chance that it exceeds 4 is e−4/2e^{-4/2}.

Write the larger as max⁡(X,Y)=12(X+Y)+12∣X−Y∣\max(X, Y) = \tfrac12(X + Y) + \tfrac12|X - Y|. The first part has mean 0, and X−YX - Y is normal with variance 2, so E∣X−Y∣=22/π=2/πE|X - Y| = \sqrt{2}\sqrt{2/\pi} = 2/\sqrt{\pi}. So the mean is 1/π1/\sqrt{\pi}.

For the second moment, there is a one-line symmetry. Replacing (X,Y)(X, Y) by (−X,−Y)(-X, -Y) turns the larger into minus the smaller, so the squares of the larger and the smaller have the same mean. They add up to X2+Y2X^2 + Y^2, with mean 2, so each has mean 1. The variance is 1−1/π1 - 1/\pi.

Why it matters. Maximum and minimum of Gaussian returns come up in tail risk and best-of options. A best-of-two option on two independent zero-mean normal returns is worth about 0.560.56 of one standard deviation.

Question 12.14 ★★ QR, QT, Risk, DS, QD • any • junior

Three machines fail after independent exponential times with rates 1, 2 and 3 per year. What is the probability that the machine with rate 1 fails last? How long does it take on average until all three have failed?

Answer

Answer to Question 12.14.

The rate-1 machine fails last with probability 7/127/12. All three have failed after 73/60≈1.2273/60 \approx 1.22 years on average.

Use the race property of exponentials: the next failure among those still working is machine ii with probability proportional to its rate, and after a failure the others start afresh, by lack of memory.

For the rate-1 machine to be last, either 2 goes first (chance 2/62/6) and then 3 beats 1 (chance 3/43/4), or 3 goes first (chance 3/63/6) and then 2 beats 1 (chance 2/32/3). That is 14+13=712\tfrac14 + \tfrac13 = \tfrac{7}{12}.

For the mean of the largest, use inclusion-exclusion on the times. The minimum of a set is exponential with the sum of the rates, so

E[max⁡]=1+12+13−13−14−15+16=7360.E[\max] = 1 + \tfrac12 + \tfrac13 - \tfrac13 - \tfrac14 - \tfrac15 + \tfrac16 = \tfrac{73}{60}.

Classic wrong answer. Using the slowest machine’s mean of 1 year, which forgets the others can fail later, or summing all the means. The largest is below the sum of the means, and above any one of them.

Question 12.15 ★★ QR, QT, DS, QD, LLE • any • junior

Orders arrive as a Poisson process at 2 per minute. How likely is one order or more in a given 30 seconds? Given that exactly 3 orders came in a given minute, what is the probability that none came in its first half? When, on average, did the first of them come?

Answer

Answer to Question 12.15.

The probability of at least one is 1−e−1≈0.6321 - e^{-1} \approx 0.632. Given exactly 3 in the minute, none came in the first half with probability 1/81/8, and the first of them came after 15 seconds on average.

In 30 seconds at 2 per minute, the count is Poisson with mean 1, so the chance of none is e−1e^{-1}.

Given the count, the arrival times are independent and uniform over the minute, whatever the rate. So all 3 fall in the second half with chance (1/2)3(1/2)^3. The first is the minimum of 3 uniforms, with mean 1/41/4 of a minute. A simulation of the actual exponential gaps, keeping only minutes with exactly 3 arrivals, confirms this.

Classic wrong answer. Using the rate’s mean gap of 30 seconds. Once you know that there are three in the minute, the gaps are shorter, and the rate has no more to say.

Why it matters. This lets you test whether events really are Poisson: given the count, times should look uniform. Clustering on news is seen at once.

Question 12.16 ★★ QR, QT, Trader, DS • any • junior

XX and YY are independent and uniform on [0,1][0, 1]. What is the distribution of the smaller of them divided by the larger? What is the average of X/YX/Y, and how is that consistent with the median of X/YX/Y being 1?

Answer

Answer to Question 12.16.

The ratio of the smaller to the larger is uniform on [0,1][0, 1]. The mean of X/YX/Y is infinite, and that sits comfortably with a median of 1.

For t∈(0,1)t \in (0, 1), the event min⁡/max⁡<t\min/\max < t is the area of the two triangles near the axes: below the line y=txy = tx and above the line y=x/ty = x/t. Each has area t/2t/2, so the chance is tt. So the ratio is uniform, and its mean is 1/21/2.

For X/YX/Y: by symmetry it is as likely to be below 1 as above 1, so the median is 1. But E[X/Y]=E[X] E[1/Y]=12∫01dy/y=∞E[X/Y] = E[X]\,E[1/Y] = \tfrac12 \int_0^1 dy/y = \infty. The tail of the distribution is too heavy, because YY can be very small.

Classic wrong answer. Giving E[X]/E[Y]=1E[X]/E[Y] = 1 as the mean of the ratio. Independence gives the product of E[X]E[X] and E[1/Y]E[1/Y], and E[1/Y]E[1/Y] is not 1/E[Y]1/E[Y].

Why it matters. Averaging ratios is dangerous for this reason, because a small denominator can dominate. Average returns over small capital bases, or a price-to-earnings mean across firms with tiny earnings, are the same problem.

Question 12.17 ★★ QR, QT, QD, Dev, DS • any • junior

You estimate π\pi by throwing nn uniform points at a unit square and counting those inside the quarter disc of radius 1 centred at one corner. What is the standard error of your estimate? About how many points do you need to be within 0.0010.001 with 95% confidence?

Answer

Answer to Question 12.17.

The standard error is about 1.642/n1.642/\sqrt{n}, and for ±0.001\pm 0.001 at 95% you need about 1.04×1071.04 \times 10^7 points.

A point falls in the quarter disc with probability p=π/4p = \pi/4. The fraction of hits has variance p(1−p)/np(1 - p)/n. The estimate is 4 times that fraction, so its standard error is 4p(1−p)/n=1.642/n4\sqrt{p(1 - p)/n} = 1.642/\sqrt{n}.

To get 1.96⋅1.642/n=0.0011.96 \cdot 1.642/\sqrt{n} = 0.001, you need n=(1.96⋅1.642/0.001)2≈1.04×107n = (1.96 \cdot 1.642/0.001)^2 \approx 1.04 \times 10^7. Each further digit needs 100 times the points.

Classic wrong answer. Thinking the error is 1/n1/n, as for a sum you add up, or that one digit more costs 10 times the work. The error falls with the square root of nn, which is why plain Monte Carlo is expensive.

Follow-up. Can you do better without more points? Yes. Stratify the square into a grid, or use a smooth control variate, or low-discrepancy points. Each gives the same answer with lower variance.

Question 12.18 ★★★ QR, QT, Risk • hedge fund, bank • junior, experienced

XX, YY and ZZ are jointly normal with mean 0, variance 1 and pairwise correlation 0.50.5. What is the probability that all three are positive? Give a formula for correlation ρ\rho. What happens at ρ=−1/2\rho = -1/2, and why is that the lowest possible value?

Answer

Answer to Question 12.18.

The probability is 1/41/4, and the general formula is 18+34πarcsin⁡ρ\tfrac18 + \tfrac{3}{4\pi} \arcsin \rho. At ρ=−12\rho = -\tfrac12 it reaches 0, which is the lowest correlation possible for three variables.

Count sign disagreements. Two of the variables differ in sign with probability d=12−arcsin⁡(ρ)/πd = \tfrac12 - \arcsin(\rho)/\pi, from the angle between them. Let aa be the chance that all three are positive, which is also the chance that all three are negative, by symmetry. A triple of mixed signs disagrees on exactly 2 of its 3 pairs, so adding up over the pairs,

3d=2(1−2a),which givesa=12−34d=18+34πarcsin⁡ρ.3d = 2(1 - 2a), \qquad\text{which gives}\qquad a = \tfrac12 - \tfrac34 d = \tfrac18 + \frac{3}{4\pi}\arcsin\rho.

At ρ=12\rho = \tfrac12, the arcsine is π/6\pi/6, and that is 18+18\tfrac18 + \tfrac18.

A second route for that value: write Xi=(W0−Wi)/2X_i = (W_0 - W_i)/\sqrt{2} with independent standard normals W0,…,W3W_0, \dots, W_3. These have correlation 12\tfrac12, and all three are positive exactly when W0W_0 is the largest of the four, which has chance 1/41/4.

Limit checks: ρ=0\rho = 0 gives 1/81/8, and ρ=1\rho = 1 gives 1/21/2. At ρ=−12\rho = -\tfrac12 you have X+Y+Z=0X + Y + Z = 0 with certainty, because the variance of the sum is 3+6ρ=03 + 6\rho = 0. They cannot all be positive, and a lower correlation would make that variance negative. So the formula has the right sign exactly at the feasibility limit.

Classic wrong answer. Giving 12⋅23⋅23=2/9\tfrac12 \cdot \tfrac23 \cdot \tfrac23 = 2/9, by chaining the pairwise sign probability. Given that XX and YY are both positive, ZZ is more likely to be positive than given XX alone: the chance is 3/43/4, not 2/32/3.

Follow-up. And nn variables at correlation 12\tfrac12? The same construction gives 1/(n+1)1/(n + 1). For a general ρ\rho and n≥4n \ge 4, there is no such simple formula, and the three-variable result is a special property of that case.

Question 12.19 ★★★ QR, QT, Trader • hedge fund, market maker • junior, experienced

A stick of length 1 is cut at 9 independent uniform points, which gives 10 pieces. What is the average length of the shortest piece? Of the longest?

Answer

Answer to Question 12.19.

The shortest averages 1/1001/100, and the longest averages H10/10≈0.293H_{10}/10 \approx 0.293.

Use the exponential representation: the nn spacings of a stick cut at n−1n - 1 uniform points have the same law as nn independent exponentials divided by their sum, and that sum is independent of the shape. So you can compute with exponentials, and divide by the mean of the sum, which is nn.

For exponentials with mean 1, the smallest of nn has mean 1/n1/n. Taking away that smallest from all of them, the other n−1n - 1 are fresh exponentials by lack of memory. So the sorted values have gaps with means 1/n1/n, 1/(n−1)1/(n-1), …, 11. The largest thus has mean HnH_n.

Divide by nn. The shortest piece has mean 1/n2=1/1001/n^2 = 1/100, and the longest Hn/n=2.929/10H_n/n = 2.929/10. The shortest is a tenth of the average piece of 0.10.1, and the longest is about three times that average.

Classic wrong answer. Giving 1/101/10 for the shortest, which is the mean position of the first cut. That is the mean of one given piece. The shortest is the minimum of ten such pieces, and it has a much smaller mean.

Why it matters. This explains how gaps in events look when they arrive at random. With 10 gaps at random times, you should expect one of them to be 3 times the average, and one to be a tenth of the average: neither means anything.

Question 12.20 ★★★ QR, QT, Trader • hedge fund, market maker • junior, experienced

A stick of length 1 is cut at 4 independent uniform points, which gives 5 pieces. What is the probability that the pieces can form a polygon with 5 sides? Give the formula for kk pieces, and say why it looks like the probability that kk points on a circle lie in a semicircle.

Answer

Answer to Question 12.20.

The probability is 11/1611/16. For kk pieces it is 1−k/2k−11 - k/2^{k - 1}.

Pieces can form a closed polygon exactly when no piece is at least the sum of the others, and because the total is 1, this means that no piece has length at least 12\tfrac12. Two pieces cannot both be 12\tfrac12 or more, except on a null set, so those events are disjoint.

A particular piece is at least 12\tfrac12 with probability (12)k−1(\tfrac12)^{k - 1}: for the first piece, all k−1k - 1 cuts must lie in the upper half, and the pieces are exchangeable. So the chance that some piece does is k/2k−1k/2^{k - 1}, and the answer is its complement. For k=5k = 5 that is 1−5/161 - 5/16, and for k=3k = 3 it is the familiar 1/41/4.

The link with points on a circle is exact. Cutting a circle at kk uniform points gives kk arcs with the same joint law as those pieces. All kk points lie in a semicircle exactly when some arc is at least 12\tfrac12. So the two formulas are one fact.

Classic wrong answer. Multiplying the triangle’s 1/41/4 by a factor for each extra piece, as if things got harder. With more pieces it gets easier, because it is less likely that any one piece is very long.

Question 12.21 ★★★ QR, QT, Trader • hedge fund, market maker • junior, experienced

Three independent uniform points on a unit circle form a triangle. What is its average area?

Answer

Answer to Question 12.21.

The average area is 32π≈0.477\frac{3}{2\pi} \approx 0.477.

Let the arcs between neighbouring points be aa, bb and cc, adding up to 2π2\pi. Join the three corners to the centre. The triangle’s area is the sum of three triangles with sides of 1 and a corner angle of an arc:

Area=12(sin⁡a+sin⁡b+sin⁡c),\text{Area} = \tfrac12 (\sin a + \sin b + \sin c),

and this works even when the centre lies outside, because the sine of an arc above π\pi is negative, and then the formula subtracts that part. The arcs have the same marginal distribution by symmetry. A single arc has density 1π(1−a2π)\frac{1}{\pi}\bigl(1 - \frac{a}{2\pi}\bigr) on (0,2π)(0, 2\pi), so

E[sin⁡a]=∫02πsin⁡aπ(1−a2π)da=1π.E[\sin a] = \int_0^{2\pi} \frac{\sin a}{\pi}\Bigl(1 - \frac{a}{2\pi}\Bigr) da = \frac{1}{\pi}.

So the expected area is 32⋅1π\tfrac32 \cdot \tfrac1\pi. A simulation of the area from coordinates matches this, and it confirms the signed formula point by point. The largest possible triangle, the equilateral one, has area 33/4≈1.303\sqrt{3}/4 \approx 1.30, so the mean is just over a third of the best.

Classic wrong answer. Taking the area of the triangle with the average arcs, 2π/32\pi/3 each, which gives the equilateral 1.301.30. Area is concave near the centre of the simplex, so the mean falls short of that value by a long way.

Question 12.22 ★★★ QR, QT, Trader • hedge fund, market maker • junior, experienced

A point is chosen uniformly in the unit square. What is the probability that it is closer to the centre of the square than to the square’s boundary?

Answer

Answer to Question 12.22.

The probability is 42−53≈0.219\frac{4\sqrt{2} - 5}{3} \approx 0.219.

Put the centre at the origin, so the square spans [−12,12]2[-\tfrac12, \tfrac12]^2. By symmetry, consider the slice of the square nearest the right side, where ∣y∣≤x|y| \le x; there are four such slices, and each is a triangle from the centre to a side. A point in it has distance to the boundary of 12−x\tfrac12 - x, and it is closer to the centre if

x2+y2<12−x  ⟺  x<14−y2,\sqrt{x^2 + y^2} < \tfrac12 - x \iff x < \tfrac14 - y^2,

which is a parabola, the locus of points as far from a point as from a line. The curve meets the slice’s edge y=xy = x where x2+x−14=0x^2 + x - \tfrac14 = 0, at y0=(2−1)/2≈0.207y_0 = (\sqrt{2} - 1)/2 \approx 0.207. So the slice has area

2∫0y0(14−y2−y)dy=2(y04−y033−y022).2\int_0^{y_0} \Bigl(\tfrac14 - y^2 - y\Bigr) dy = 2\Bigl(\frac{y_0}{4} - \frac{y_0^3}{3} - \frac{y_0^2}{2}\Bigr).

Multiplying by 4 gives (42−5)/3(4\sqrt{2} - 5)/3. As shown in Figure 12.2, the region is a square with bulging sides. Its area lies between that of the disc of radius 14\tfrac14, which is about 0.1960.196, and that of the disc of radius 12\tfrac12.

The points of the unit square closer to the centre than to the boundary. Each of the four arcs is a parabola, with the centre as focus and a side as directrix. The dashed diagonals split the square into four slices.
Figure 12.2. The points of the unit square closer to the centre than to the boundary. Each of the four arcs is a parabola, with the centre as focus and a side as directrix. The dashed diagonals split the square into four slices.

Classic wrong answer. Using a disc of radius 14\tfrac14, which gives π/16≈0.196\pi/16 \approx 0.196. That is right only along the axes. Towards a corner the boundary is further away, so the true region reaches beyond the disc, as far as a distance of about 0.2930.293 from the centre.

Question 12.23 ★★★ QR, QT, Trader • hedge fund, market maker • junior, experienced

A very large number of birds sit at independent uniform positions along a wire. Each bird paints the stretch of wire between itself and its nearest neighbour. What fraction of the wire is painted?

Answer

Answer to Question 12.23.

The painted fraction is 7/18≈0.3897/18 \approx 0.389.

For many birds, the gaps between neighbours behave like independent exponentials. Take the gap containing a random point of the wire. It is size-biased, so with mean gap 1, its length LL has density Le−LLe^{-L}.

The gap is painted when at least one of its two end birds has it as its shorter side. The bird on the left does not paint it if that bird’s other gap is shorter than LL, which has chance 1−e−L1 - e^{-L}. The two other gaps are independent, so the gap stays unpainted with chance (1−e−L)2(1 - e^{-L})^2. Averaging:

E[(1−e−L)2]=∫0∞Le−L(1−2e−L+e−2L)dL=1−24+19=1118.E[(1 - e^{-L})^2] = \int_0^\infty Le^{-L}\bigl(1 - 2e^{-L} + e^{-2L}\bigr) dL = 1 - \tfrac24 + \tfrac19 = \tfrac{11}{18}.

So 11/1811/18 stays unpainted and 7/187/18 is painted, which a simulation of birds on a wire matches.

Classic wrong answer. Saying one half or more, on the grounds that every bird paints something. Short gaps get painted, sometimes by both ends, and long gaps tend not to be. Long gaps hold most of the wire.

Follow-up. What fraction of gaps, as a count, gets painted? Without size-biasing the density of LL is e−Le^{-L}, and the chance of being unpainted has mean 1−2⋅12+13=131 - 2 \cdot \tfrac12 + \tfrac13 = \tfrac13, so 2/32/3 of the gaps are painted. Those are the short ones, which is why they hold only 7/187/18 of the length.

Question 12.24 ★★★★ QR, QT • hedge fund, market maker • experienced

Four independent uniform points on a sphere are the corners of a tetrahedron. What is the probability that it contains the centre of the sphere? Find a proof that needs no integral.

Answer

Answer to Question 12.24.

The probability is 1/81/8.

Draw the points as follows: first choose four random lines through the centre, and then choose one of each line’s two points by flipping a coin. That is the same as choosing four independent uniform points. There are 16 sign choices, and you only have to count how many of them give a tetrahedron around the centre.

Fix the point p4p_4 on the fourth line. The other three lines each give two choices, and these make the 8 spherical triangles into which the three great circles (through pairs of the lines) cut the sphere. The eight triangles cover the sphere with no overlap, except for edges. The tetrahedron with corners ±p1,±p2,±p3,p4\pm p_1, \pm p_2, \pm p_3, p_4 contains the centre exactly when −p4-p_4 lies in the triangle ±p1,±p2,±p3\pm p_1, \pm p_2, \pm p_3. Exactly one of the eight triangles contains −p4-p_4. So the chance is 1/81/8, whichever p4p_4 you have.

The same argument on a circle gives 1/41/4, and in general, in dd dimensions, the chance that d+1d + 1 points surround the centre is 2−d2^{-d}. Wendel’s sum extends this to more points.

Classic wrong answer. Trying to integrate over solid angles. The trick removes all of the calculation. This is what the interviewer hopes you will find, perhaps after the two-dimensional case.

Follow-up. And all four in some hemisphere? The complement: 7/87/8. Wendel’s sum for d=3d = 3 and n=4n = 4 is 2−3((30)+(31)+(32))=7/82^{-3}\bigl(\binom30 + \binom31 + \binom32\bigr) = 7/8.

Question 12.25 ★★★★ QR, QT • hedge fund, market maker • experienced

A floor has a square grid of lines, one unit apart in each direction. You drop a needle of length 1 at a random position and angle. What is the average number of grid lines it crosses? What is the probability that it crosses at least one?

Answer

Answer to Question 12.25.

It crosses 4/π≈1.2734/\pi \approx 1.273 lines on average, and it crosses at least one with probability 3/π≈0.9553/\pi \approx 0.955.

The mean is linearity. The grid is two sets of parallel lines, and Buffon’s result gives 2/π2/\pi crossings from each, so together 4/π4/\pi.

For the chance of at least one, fix the angle θ∈(0,π/2)\theta \in (0, \pi/2) to one of the directions; other angles are the same by symmetry. Horizontal and vertical positions are independent, so the needle misses both sets with probability (1−cos⁡θ)(1−sin⁡θ)(1 - \cos\theta)(1 - \sin\theta). Averaging over θ\theta with density 2/π2/\pi:

2π∫0π/2(1−cos⁡θ)(1−sin⁡θ)dθ=2π(π2−1−1+12)=1−3π.\frac{2}{\pi} \int_0^{\pi/2} (1 - \cos\theta)(1 - \sin\theta) d\theta = \frac{2}{\pi}\Bigl(\frac{\pi}{2} - 1 - 1 + \frac12\Bigr) = 1 - \frac{3}{\pi}.

Inclusion-exclusion gives the same: each set is crossed with chance 2/π2/\pi, and both with chance 2π∫0π/2cos⁡θsin⁡θ dθ=1/π\frac{2}{\pi}\int_0^{\pi/2}\cos\theta\sin\theta\, d\theta = 1/\pi, so the chance of at least one is 4/π−1/π4/\pi - 1/\pi.

A needle of this length crosses some line almost every time, but it crosses lines of both directions only about a third of the time.

Classic wrong answer. Using 2⋅2/π−(2/π)22 \cdot 2/\pi - (2/\pi)^2, treating the two sets as independent. Positions are independent, but the angle is shared: a needle lying near one direction crosses that set less, and the other set more.

Why it matters. Mixing over a shared hidden factor creates dependence, even when each piece is independent given it. Treat hidden common factors as the first thing to check in any calculation of the chance of joint events.