本书暂未推出简体中文版。现有版本:English, Français。
Interviews I: Maths, Probability and Speed · 职业发展
13Order Statistics
Working with the sorted values of a sample: maximum and median, spacings, the highest serial number seen, the second-highest bid, records. Ranks are the common thread, because the rank pattern of a sample does not depend on its distribution.
Question 13.1 ★ QR, QT, Trader, Analyst • any • junior
You draw independent uniform numbers on . What are the averages of the largest, of the smallest and of the range? Give the probability that the largest is below when .
Answer
Answer to Question 13.1.
The largest averages , the smallest and the range . For , the largest is below with probability .
The points cut the interval into pieces, and these pieces are exchangeable, so each has mean . The smallest is the first piece, the largest is everything except the last piece, and the range is everything except the two end pieces. The largest is below a value exactly when all are.
The case checks all three: the largest and smallest both average , and the range is 0.
Classic wrong answer. Giving for the largest. That is the point below which a single draw falls with chance , not the mean of the largest. It is close for large , and wrong for .
Question 13.2 ★ QR, QT, DS, Analyst • any • junior
You draw three independent uniform numbers on . What is the density of their median? What are its mean and variance? Which estimates the centre of the distribution better, the median of the three or their average?
Answer
Answer to Question 13.2.
The density is , the mean is and the variance is . The average is better, with a variance of .
The median is near when one point is near , one below and one above. There are ways of assigning those roles, which gives the density . In general, the -th smallest of uniforms has a Beta law, here Beta. By symmetry the mean is , and , so the variance is .
The average of three has variance , so the median is times as variable.
Classic wrong answer. Saying the median is always the more robust choice, so it must be the better one. Robustness protects against outliers, and a uniform has none. On a distribution with hard edges, the extremes are the most informative values.
Question 13.3 ★ QR, QT, Trader, DS • any • junior
Desk A sends 10 orders and desk B sends 20, and all 30 latencies are independent draws from the same continuous distribution. What is the probability that the fastest order belongs to desk B? That the three fastest all belong to desk B? Does the answer depend on the distribution?
Answer
Answer to Question 13.3.
The fastest belongs to desk B with probability , and the three fastest all belong to it with probability . The distribution does not matter.
All 30 values come from one continuous distribution, so every ordering of them is equally likely. The labels A and B are therefore a random assignment of 10 and 20 positions in the sorted list. The chance that the first three positions all go to B is the chain .
This is what rank tests are based on. If the fastest three all came from one desk, you can compute that chance under “same distribution” with no model of latency at all.
Classic wrong answer. Cubing , which gives about . That treats the positions as independent, when they are drawn without replacement.
Follow-up. What is the test that this leads to? The Mann–Whitney rank test: it sums the ranks of one group and compares them with the distribution of all possible assignments.
Question 13.4 ★★ QR, QT, DS, Analyst • any • junior
A batch of machines carries the serial numbers , with unknown. You see five different machines, picked at random, and the highest serial number among them is 60. Give an unbiased estimate of , and derive it. Why is twice the sample mean minus one a worse estimator, even though it is unbiased as well?
Answer
Answer to Question 13.4.
The unbiased estimate is . Twice the mean minus one has a variance times as large, about against at .
The highest of serial numbers has , and summing gives . So , and replacing by what you saw gives an unbiased estimator.
There is a picture behind this. The numbers split into gaps of the same average length. The numbers above the maximum are one gap, and the average of the gaps you can see is about . So add that to .
The sample mean has mean , so doubling it and taking off one is unbiased too, but the highest number carries all the information in the sample. Given the maximum, the other numbers are just uniform below it and say nothing more about . The mean rule ignores this, and with a sample it gives 27, which is below a serial number you have actually seen.
Why it matters. Know which single number in a sample carries the information, and do not average it away. The same reasoning applies whenever a series has a hard edge, such as a position limit or a price floor.
Question 13.5 ★★ QR, QT, DS • any • junior
You have independent draws from a uniform on . Compare the variance of with the variance of for . Both are unbiased. Which multiple of the maximum has the smallest mean squared error, and what is it worth?
Answer
Answer to Question 13.5.
The variances are and for , so the mean is 4 times as variable. The best multiple is , with mean squared error , here against .
Take . The mean has variance , so has variance . The maximum has and , so , and the scaled maximum has variance . The ratio is .
Note the rates: for the mean against for the maximum. An edge of a distribution is learned far faster than its centre.
For , the mean squared error is , a parabola in with its minimum at . This accepts a small bias for a lower variance, but the gain is tiny, against . The raw maximum, the maximum-likelihood estimate, has error , nearly twice as much.
Classic wrong answer. Saying the maximum-likelihood estimate is the best because it usually is. Here it is biased low by construction, as it can never exceed the true .
Question 13.6 ★★ QR, QT, Trader, Analyst • market maker, hedge fund • junior
Five bids are independent and uniform on . What is the average of the second-highest bid? If you are told that the highest bid is , what is the average of the second-highest then? Separately, you roll four fair dice: what is the average of the second-highest number shown?
Answer
Answer to Question 13.6.
The second-highest of five bids averages . Given that the highest is , it averages . The second-highest of four dice averages .
From the gaps: the second-highest is everything except the top two of the six equal-mean pieces, so its mean is .
Given the highest is , the other four are independent uniforms on , and the second-highest is the largest of them, with mean . At that is . As a check on the two answers, the highest has density , and averaging over that gives .
For the dice, use the tail sum. The second-highest is at least when at least two of the four dice are, so with ,
and adding this for gives .
Classic wrong answer. Using the uniform result for the dice, taking . A die is not a rescaled uniform, and ties make the answer slightly different.
Why it matters. In a second-price auction the winner pays the second-highest value, so this average is the seller’s revenue. Knowing the top bid changes it, because the others are then bounded by it.
Question 13.7 ★★ QR, QT, DS, Risk • any • junior
For a large sample from a normal distribution, how much more variable is the sample median than the sample mean? What is the same comparison for the Laplace distribution, with density ? What does this suggest for fat-tailed returns?
Answer
Answer to Question 13.7.
For a normal sample the variance of the median is times that of the mean. For the Laplace it is half that of the mean. So with fat enough tails the median wins.
The sample median has asymptotic variance , with the density at the true median. The reason is that around the median, the count of points below a level is binomial with variance , and the slope of the expected count is ; dividing gives the error in position.
Standard normal: , so the variance is , against for the mean.
Laplace: , so the variance is , while the mean has variance .
Classic wrong answer. Saying the median is always less efficient because it “throws data away”. It depends on the density at the centre compared with the tails. A peak at the centre and fat tails favour the median.
Follow-up. And at the extreme of fat tails? For a Cauchy sample the mean is no better than one draw, whatever is, while the median has variance . Real returns sit between the normal and these cases, which is why a trimmed mean or a median of a daily series is worth computing beside the mean.
Question 13.8 ★★ QR, QT, Risk, QD • any • junior
Five servers fail after independent exponential times with mean one year. When, on average, does the first fail? The third? The last? Are the time of the first failure and the time from the first failure to the last independent?
Answer
Answer to Question 13.8.
The first fails after of a year on average, the third after , the last after . The time of the first failure and the time from it to the last are independent.
Five running servers fail at a total rate of 5, so the first failure takes on average. By lack of memory, the remaining four then start afresh, with rate 4, and so on. So the sorted times are sums of independent gaps with means .
The third is , and the last is the sum of all five. The time from first to last is a sum of the other four gaps, so it is independent of the first, with mean .
This independence is a special property of exponentials. In a uniform sample, a large minimum leaves little room, so the minimum and the range are strongly negatively correlated. A simulation finds about zero correlation for the exponentials, and below for uniforms.
Classic wrong answer. Using one year for the last, the mean of a single lifetime. The last of five has to outlive the others, and that takes more than twice as long.
Why it matters. This is the standard picture for hardware failures with redundancy. With three replicas the time until the last is lost grows only slowly with redundancy, as a harmonic sum, unless you repair in between.
Question 13.9 ★★ QR, QT, DS • any • junior
You draw independent numbers from a continuous distribution until one beats your first draw. Let be the number of further draws you need. What is ? What is the smallest with , and what is the mean of ? Are the events “draw 5 is a record” and “draw 10 is a record” independent?
Answer
Answer to Question 13.9.
. The smallest with is 1, and the mean is infinite. The record events are independent.
means that the first draw is the largest of the first . All orderings are equally likely, so each of the draws is the largest with the same chance.
exactly, and , so the smallest such is 1. The median is not unique, because as well: every number from 1 to 2 is a median. The mean is the sum of the tail probabilities, , which diverges. If the first draw happens to be large, the wait is very long, and those rare cases dominate the average.
For the records: draw being a record is a statement about where the largest of the first lies. The relative order of the first 9 draws, in particular where the largest of the first 5 stands, is independent of whether draw 10 beats them all. So the chance of both is , which a simulation confirms.
Classic wrong answer. Saying that the average wait must be finite because you nearly always finish after a few draws. The chance of a long wait falls too slowly, like , for the sum to converge.
Why it matters. In a series of independent draws, a new all-time high gets rarer and rarer. A long run with no new high is expected under that model, and it says nothing on its own about a change.
Question 13.10 ★★ QR, QT, DS, Risk • any • junior
You have 10 independent draws from an unknown continuous distribution. What is the probability that its true median lies between the smallest and the largest draw? Between the third smallest and the third largest? Why can you say this with no knowledge of the distribution?
Answer
Answer to Question 13.10.
Between the smallest and the largest: . Between the third smallest and the third largest: .
Each draw is below the true median with probability exactly , whatever the distribution. So the number of draws below the median is binomial with and .
The median exceeds the smallest draw unless , and it is below the largest unless , which gives the first answer. The median lies between the third smallest and third largest exactly when at least 3 draws are below it, and at least 3 above it, which means :
A simulation with exponential and normal draws gives the same two numbers.
Classic wrong answer. Using a normal interval on the sample, . It needs assumptions you have not got. For a median, the binomial count gives an exact interval.
Follow-up. Does this work for the mean? No. A distribution can have the same median with any mean you like, because of a far-away small probability. No interval made from a finite sample can cover the mean under every distribution.
Question 13.11 ★★★ QR, QT, DS • hedge fund, market maker • junior, experienced
A researcher backtests 1000 independent strategies, all with a true Sharpe ratio of 0. Each measured annual Sharpe ratio is normal, centred on 0, with a standard deviation of , which corresponds to 9 years of data. About what is the best measured Sharpe ratio, working without a table? How does the expected best grow with the number of strategies tried?
Answer
Answer to Question 13.11.
The best measured Sharpe ratio is about , since the largest of 1000 standard normals averages about . The expected best grows like , very slowly.
Hand estimate: the largest of sits near the level exceeded with chance . Here that is , which is standard deviations, and using the median of the maximum, with tail , it is . Multiply by , and you get about . The exact mean, from , is , which a simulation matches.
The formula has the right growth, but it is too high by half a standard deviation at this size. Going from 100 to 1000 strategies, or from 1000 to 10 000, adds only about to standard deviation.
With one strategy there is no selection, and the expected best is 0.
Classic wrong answer. Saying that 1.08 over nine years is too high to be luck, because its -statistic is above 3. That test is for one strategy chosen in advance. After 1000 tries you should expect that value when no strategy has any skill.
Why it matters. This is the first question to ask of a backtest: how many things were tried? A corrected hurdle needs the number of trials, and the true number includes the attempts nobody wrote down.
Question 13.12 ★★★ QR, QT, Risk, DS • any • junior, experienced
You draw independent uniform numbers on . Find the distribution of the range. How large must be for the probability to be at least 95% that the range covers at least 90% of the interval? What can you then say, with the same , about any continuous distribution?
Answer
Answer to Question 13.12.
, and you need draws, where the chance of falling short is (against for ). For any continuous distribution, with 95% confidence, at least 90% of the distribution lies between the smallest and largest of 46 draws.
Take the range below . Say the smallest point is the one at , chosen in ways, and then the other must lie in . For this has chance , and for above that, the chance is . So
which is the formula. A check: for , it gives , which matches .
For a general distribution with cumulative function , the values are uniform. The mass between the smallest and largest sample is exactly the uniform range , so the result holds with no assumption.
Classic wrong answer. Solving , which gives . That is right for one-sided cover, with only the maximum. Covering both ends takes more draws.
Why it matters. This gives a stress band with no model: 46 observed days bound 90% of the distribution with 95% confidence, whatever the returns look like, so long as the days are independent and from one distribution. They are often neither.
Question 13.13 ★★★ QR, QT, DS • hedge fund • junior, experienced
A sample of size 11 comes from a uniform on , with unknown. Compare three estimators of the centre: the sample mean, the sample median and the midrange, which is the average of the smallest and largest. Give the three variances. Why does the midrange win here, and at what rate does its variance fall as the sample grows?
Answer
Answer to Question 13.13.
The variances are for the mean, for the median and for the midrange. The midrange wins, and its variance falls like .
For the mean, the variance is . The median of uniforms has a Beta law, with variance , here . For the midrange, the maximum and minimum have the same variance and covariance , so
A simulation matches all three within 1%. For all three coincide, at , which is another check.
The midrange wins because the density has hard edges and is flat inside. The likelihood depends only on the two extremes, so given them, the rest of the points have no further information on . The median is worst, because it only uses local information, at a place with no special feature.
Classic wrong answer. Recommending the midrange in general. It is the worst choice with fat tails, and on a normal sample its variance is already above the mean’s. A simulation at shows it more than times higher. An estimator suits a shape, and there is no universally good one.
Question 13.14 ★★★ QR, QT, LLE, QD • market maker, crypto • junior, experienced
Ten orders arrive at independent uniform times within one second. What is the probability that no two of them are within 10 milliseconds of each other? What is the average of the smallest gap between neighbouring orders?
Answer
Answer to Question 13.14.
No two are within 10 ms with probability . The smallest gap averages of a second, about ms.
The direct route is a shrinking argument. Give the points in sorted order , all with gaps at least . Take . This is a one-to-one map from such sets to sorted sets of points in , and it preserves volume. So the chance that all gaps are at least is
here . The formula gives 1 at and 0 when , when the points cannot fit any more.
The mean of the smallest gap is the integral of that tail, . So a chance of about at a distance of 10 ms sits beside a mean of about 10 ms, and this is a law with a long upper tail.
Classic wrong answer. Giving , by treating the 45 pairs as independent, each with chance of being close. It is an approximation for rare events, and it comes out near the exact value, but here the pairs are not independent, and it would fail for a larger .
Why it matters. Bursts occur at random. Ten orders in a second will come within 10 ms of each other more often than not, so a matching engine or a risk check has to be designed for that, even if the average gap is 100 ms.
Question 13.15 ★★★★ QR, QT • hedge fund, market maker • experienced
Find, in closed form, the average of the largest of three independent standard normal variables, and then the average of the largest of four. Your method should not need numerical integration. How far does the same method go, and what stops it?
Answer
Answer to Question 13.15.
The largest of three averages , and the largest of four averages . The method goes up to five (about ), and six would need the chance that four correlated normals are all positive, for which there is no simple formula.
Start with . Since , integrate by parts:
Now, times the density of . So
and is the chance that new independent standard normals are all below . The differences have variance , and any two of them have covariance , so correlation . The chance that they are all negative is an orthant probability.
For : one variable, chance , so .
For : two variables, chance , and multiplying by gives the stated formula.
For : three variables, chance , so . All three match a numerical integral to nine decimals.
A second route for uses no integrals at all. The three pairwise distances add up to twice the range. Each has mean , so the range has mean , and the largest has half of that, because the smallest has the same size with the sign changed.
Classic wrong answer. Using , which gives for . It is an asymptotic growth rate, and it is far from correct at small . A quant should know the small values: , , , for to .