Hedge Funds puzzles, solved step by step
- Puzzles
- 100
- Traced to a firm
- 38
- Topics
- 14
- Hard
- 30
004A risk system estimates a full covariance matrix for a 50-stock book. How many distinct correlations must it estimate, and how many parameters in total?Quant and systematic fundsProp and quant trading firms
Try it first
Quick: how many distinct correlations are there among 50 stocks?
Show the worked solution
1,225 correlations and 1,275 parameters in all. A covariance matrix is symmetric, so only the cells above the diagonal carry new information: one per pair of stocks, 50 x 49 / 2 = 1,225. The diagonal holds the 50 variances. The count grows with the square of the number of names, which is why large books estimate risk through a handful of factors instead.
Why do you count pairs rather than cells?
In a class of 50, how many handshakes happen if everyone shakes everyone else's hand once? Each person shakes 49 hands, but every handshake has been counted twice, once from each side, so it is 50 x 49 / 2 = 1,225. A correlation is a handshake: it belongs to a pair, and the pair A and B is the same pair as B and A. The diagonal is each stock paired with itself. Its correlation is 1 and needs no estimating, but the diagonal of the covariance matrix holds each stock's variance, which does.
In a 50 by 50 covariance matrix only the 1,225 cells above the diagonal and the 50 on it need estimating, 1,275 parameters in all, against 315 for a five factor model; at 500 names the full matrix needs 125,250, more than a year of daily returns supplies. The relationshipN the number of stocks, here 50 N(N-1)/2 the number of distinct pairs What it says in wordsPairs plus the diagonal gives the full count of numbers a covariance matrix needs.Why does the count become a problem for a big book?
Because it grows with the square of the names. Ten times as many stocks needs about a hundred times as many correlations: 500 names need 124,750 of them plus 500 variances, 125,250 parameters. A year of daily returns on 500 names is 250 x 500 = 125,000 numbers, fewer than the parameters being estimated. With fewer days than stocks the sample matrix is singular: some combinations of positions appear to carry zero risk, and an optimiser will pile into exactly those.
What does a factor model buy you?
A factor model says each stock's return is driven by a few shared drivers, such as the market, its sector and its size, plus noise of its own. With 5 factors, 50 stocks need 250 loadings, 50 specific variances and 15 factor covariances: 315 numbers instead of 1,275. At 500 names it is 3,015 instead of 125,250. The limitation is worth saying: any risk the factors do not name is assumed independent across stocks, and in a crowded unwind that assumption is the first to break.
Where candidates lose it
The quick wrong answer is 2,500, the number of cells. It double counts every pair and treats the diagonal as correlations. The interviewer expects the handshake formula in one breath.
The bigger miss is stopping at the number. The question is really about why nobody estimates this matrix directly for a large book; if you never reach the squared growth and the factor model, you have answered the arithmetic but not the question.
What the interviewer asks next
- How many days of data do you need before the sample covariance matrix of 50 stocks can even be inverted?
- What is shrinkage, and why does it help here?
- How many parameters does a 3-factor model need for 200 stocks?
016How many rolls of a fair die do you expect to need before you have seen all six faces at least once?Quant and systematic fundsProp and quant trading firms
Try it first
Your estimate?
Show the worked solution
14.7 rolls. Split the wait into six stages, one per new face. The first roll always shows a new face. With k faces already seen, each roll is new with probability (6 - k)/6, so that stage takes 6/(6 - k) rolls on average. Adding 1 + 1.2 + 1.5 + 2 + 3 + 6 gives 14.7, and the last face alone costs six of those rolls.
Why does the wait get longer as you go?
Collecting a set of six cricket cards from cereal packets feels quick at first: almost every packet brings a new card. By the end you are opening packet after packet for the one card you lack. The chance of something new falls as the collection grows, so the wait for each new face grows too, and the last face dominates. With five faces seen, only one roll in six is any use.
The expected rolls for each new face rise from 1 for the first to 1.2, 1.5, 2, 3 and finally 6 for the last, adding to 14.7 rolls, with the final face alone taking 6. The relationshipk the number of faces already seen 6/(6 - k) the expected rolls to find one more new face What it says in wordsThe total wait is the sum of six geometric waits, each longer than the last.Why is each stage 6/(6 - k) rolls?
Each stage is a run of independent tries with a fixed chance of success, and the average length of such a run is one over that chance. If a new face turns up with probability p on each roll, you wait 1/p rolls on average: 6/5 rolls when five faces are still new, 6/1 when only one is. That rule, the mean of a geometric wait, is the one piece of theory the puzzle needs, and it is worth saying before you start adding.
Where does the same shape show up in markets?
Any wait to see every one of a set of outcomes has a long tail. Waiting until every stock on a thin watch list has traded at least once, or until a survey has reached every group in a sample, behaves the same way: most of the time goes on the last few. The general answer is n times the sum 1 + 1/2 + ... + 1/n, which grows like n times the natural log of n; for 100 equally likely items it is about 519 draws, not 100.
Where candidates lose it
Answering 6 assumes no repeats. Candidates usually sense that is wrong but then guess 10 or 12 instead of splitting the wait into stages.
The other slip is adding the probabilities instead of their inverses. The stages are waits, and a wait for an event of probability p lasts 1/p rolls on average; state that rule before you sum.
What the interviewer asks next
- How many rolls on average to see every face of a 20-sided die?
- What is the expected number of distinct faces seen in six rolls?
- How many rolls on average to see a 6 twice?
029You roll a fair six-sided die six times. What is the expected number of distinct faces you see?Quant and systematic fundsProp and quant trading firms
Try it first
Pick the closest before you calculate.
Show the worked solution
About 3.99, so roughly four. Give each face its own yes-or-no: did it appear at least once? A face is missed in all six rolls with chance (5/6)^6, about 33.5%, so it appears with chance about 66.5%. The expected count is the sum of the six chances: 6 x (1 minus (5/6)^6), which is 3.9906.
Why not work out the chance of seeing exactly 1, 2, up to 6 faces?
You could, but each of those needs a fiddly count. There is a shortcut that works whenever the question asks for an expected count. Think of a teacher checking attendance: the expected number present is simply the sum, over pupils, of each pupil's chance of turning up. Write the total as a sum of yes-or-no indicators, one per face, and the expected total is the sum of their probabilities, whether or not they are independent. That rule is {term('linearity of expectation', 'The expected value of a sum equals the sum of the expected values, even when the parts depend on each other.')}, and it turns a hard count into one line.
What is the chance that a given face shows up?
It is easier to find the chance it does not. Each roll misses the face with chance 5/6, and the six rolls are independent, so the face is missed every time with chance (5/6)^6, which is 15,625 over 46,656, about 33.5%. So each face appears at least once with chance about 66.5%, and six faces give 3.99. The indicators are not independent, since seeing face 1 a lot leaves less room for face 2, but linearity does not care.
Each of the six faces appears at least once in six rolls with probability 66.5% and is missed with probability 33.5%, so the expected number of distinct faces is 6 x 0.6651, about 3.99. The relationshipf a face of the die, 1 to 6 (5/6)^6 the chance a given face is missed in all six rolls What it says in wordsThe expected number of faces seen is six times the chance any one face is seen.Give the general form and a sense check. With n faces and n rolls the answer is n(1 minus (1 minus 1/n)^n), which tends to n(1 minus 1/e), about 63% of n. For a die that predicts 3.79, and the exact 3.99 is a little higher because six is small. The same logic tells a desk how many distinct names a random sample of trades touches.
Where candidates lose it
The first loss is saying six, or five, from instinct. The chance that six rolls give six different faces is 720 over 46,656, about 1.5%, so repeats are the normal case.
The second loss is trying to build the full distribution of distinct faces under time pressure and running out of time. Say indicator variables in the first sentence and the question is a one-liner.
What the interviewer asks next
- How many rolls do you expect to need before you have seen all six faces?
- What is the expected number of faces that appear exactly once in six rolls?
- What is the variance of the number of distinct faces?
054You flip a fair coin five times. What is the probability of seeing a run of at least three heads in a row somewhere in the five flips?Quant and systematic fundsProp and quant trading firms
Try it first
What is the chance of at least three heads in a row in five flips?
Show the worked solution
The chance is 8 in 32, exactly 1/4. Sort the qualifying sequences by where their first run of three heads starts. Starting at flip 1: HHH then anything, 4 sequences. Starting at flip 2: flip 1 must be tails, then HHH, then anything, 2 sequences. Starting at flip 3: flip 2 must be tails and flip 1 is free, 2 sequences. Four plus two plus two is eight.
Why does the obvious count go wrong?
Suppose you count guests at a party by asking each room how many people it holds, while some guests stand in doorways. They get counted twice. A run of three can start in three places, but one sequence can contain a run starting at more than one of them, so three places times four fillings, 12, counts HHHHH three times and two other sequences twice. The fix is to give each sequence exactly one home: the position where its first run starts.
The eight qualifying sequences sort into four whose first run starts at flip 1, two at flip 2 and two at flip 3, so the chance is 8 of 32, one quarter; the naive count of 12 counts overlapping runs more than once. How do you make every sequence count once?
Force the flip just before the run to be tails. If the first run starts at flip 2, flip 1 must be tails; if it starts at flip 3, flip 2 must be tails, and flip 1 can be anything. That gives 4, then 2, then 2. Then check a second way by counting the complement: sequences with no run of three follow a Tribonacci-style rule, each term the sum of the three before, giving 1, 2, 4, 7, 13, 24 for 0 to 5 flips. And 32 minus 24 is 8.
The relationship2^2 first run at flip 1: the last two flips are free 2 first run at flip 2 or 3: one free flip each 24 sequences with no run of three heads What it says in wordsCount each qualifying sequence once, by the start of its first run, and confirm by counting the sequences that fail.Why would a quant fund ask this?
Streaks are what people notice in trading records and backtests. A run of three heads turns up in a quarter of all five-flip sequences of a fair coin, so a short winning streak is weak evidence of skill. The counting habit matters as much as the number: giving each outcome one home is the same discipline that stops you double counting overlapping signals when you tally how often a strategy fired.
Where candidates lose it
The trap is 12 out of 32: three places a run can start times four fillings of the other flips. It sounds rigorous, and it is wrong because a sequence with a long run is counted once for every place a run of three fits inside it.
The second loss is giving 1/4 with no check. Offer the complement count, 24 sequences with no run of three, as the second route to the same answer.
What the interviewer asks next
- What is the chance of at least three heads in a row in ten flips?
- In five flips, what is the chance of a run of exactly three heads, no longer?
- How many flips do you expect to make before you first see three heads in a row?
079Five cards are dealt from a well-shuffled 52-card deck. What is the probability that the hand holds at least one ace?Quant and systematic fundsProp and quant trading firms
Try it first
Which route gets you to the answer fastest and safely?
Show the worked solution
About 34.1%. Count the opposite. A hand with no ace is five cards from the 48 non-aces: 1,712,304 hands out of 2,598,960, or 65.9%. So at least one ace comes up about 34.1% of the time. Adding up exactly one, two, three and four aces reaches the same 886,656 hands, but takes four calculations instead of one.
Why count the hands without an ace?
If someone asks whether at least one of your five friends will be late to dinner, you do not add the chances of exactly one late, exactly two late and so on. You ask the chance that everyone is on time and subtract it from one. At least one is a collection of four separate cases, while none is a single case, so the complement turns four calculations into one.
Deal the cards one at a time. The first card misses the aces with chance 48/52, the second with 47/51, and so on down to 44/48. Multiply the five fractions and you get 0.6588. The same number is C(48,5) over C(52,5), which is 1,712,304 over 2,598,960.
Adding the hands with exactly one, two, three and four aces gives 886,656 of 2,598,960 hands, 34.1%; counting the 1,712,304 hands with no ace and subtracting from one gives the same 34.1% in a single step. The relationshipC(48,5) the number of five-card hands drawn only from the 48 cards that are not aces C(52,5) the number of all possible five-card hands What it says in wordsThe chance of at least one ace is one minus the share of hands that contain none.Why is 5 x 4/52 wrong, and what does it actually measure?
Five times 4/52 is 38.5%, and it sounds reasonable. It adds up the chance that each card is an ace, which counts a hand with two aces twice and a hand with four aces four times. What it really gives is the expected number of aces in the hand, 0.385, which is always at least the chance of seeing one. The two drift further apart as the hand grows: deal fourteen cards and the same method gives more than 100%.
How do you check the answer the long way?
Exactly one ace: 4 ways to pick the ace times C(48,4) = 194,580 for the rest, 778,320 hands. Two aces: 6 x 17,296 = 103,776. Three: 4 x 1,128 = 4,512. Four: 48. The four cases sum to 886,656 hands, 34.1% of 2,598,960, matching the complement. Offer this as the check if there is time, never as the first route.
Where candidates lose it
The common loss is 5 x 4/52, about 38.5%, said quickly and with confidence. It is the expected number of aces, not the probability of at least one, and the interviewer will follow up with fourteen cards, where the same method gives more than 100%.
The second loss is starting on the direct sum and running out of time on the three-ace and four-ace terms. Reach for the complement the moment you hear the words at least one.
What the interviewer asks next
- What is the probability of exactly two aces?
- How many cards must you deal before at least one ace is more likely than not?
- What is the expected number of aces in a five-card hand, and why is it larger than the chance of at least one?
091Cards are turned over one at a time from a well-shuffled 52-card deck. On average, at what position does the first ace appear?Quant and systematic fundsProp and quant trading firms
Try it first
What is the expected position of the first ace?
Show the worked solution
Position 10.6. The four aces split the 48 non-aces into five gaps: before the first ace, between each pair of aces, and after the last. By symmetry, a given non-ace is equally likely to fall in any of the five gaps, so each gap holds 48/5 = 9.6 cards on average. The first ace comes straight after the first gap, at 9.6 + 1 = 10.6.
Why do the gaps have the same size on average?
Picture four red beads threaded at random among 48 white ones on a string. Pick any one white bead: it is as likely to sit before all four reds as between the first and second, or after the last, because a shuffle favours no order. Each non-ace lands in each of the five gaps with probability 1/5, so the expected size of every gap is 48/5 = 9.6 cards. Any single shuffle has uneven gaps; it is only the average that is equal.
One shuffle leaves uneven gaps of 4, 5, 14, 11, 14 non-aces around its four aces, but averaged over all shuffles every one of the five gaps holds 9.6 cards, so the aces sit at 10.6, 21.2, 31.8, 42.4. How do you turn gap sizes into a position?
The first ace sits immediately after the first gap. Expected position = expected size of the first gap + 1 = 9.6 + 1 = 10.6. The same logic puts the second ace at 21.2, the third at 31.8 and the last at 42.4, evenly spaced 10.6 apart. A quick check: the last ace at 42.4 plus a final gap of 9.6 reaches exactly 52.
The relationshipn cards in the deck, 52 k special cards, here the 4 aces (n - k)/(k + 1) the expected number of ordinary cards in each of the k + 1 gaps What it says in wordsWith n cards and k special ones, the first special card is expected at position (n + 1) divided by (k + 1).Why is 13 the wrong instinct?
Thirteen is the average wait when every draw has a fresh 1-in-13 chance, as if each card were put back and the deck reshuffled. Drawing without replacement makes the aces easier to reach, because every non-ace you turn over raises the share of aces in what is left. The general rule, (n + 1)/(k + 1), is worth keeping: the first spade is expected at 53/14, about card 3.79, and the same shape answers how many trades you expect to check before finding the first of a handful of booking errors in a batch.
Where candidates lose it
The fast wrong answer is 13, borrowed from a wait with replacement. The interviewer wants to see you notice that the deck is finite, so the first ace must appear by card 49 at the latest and is pulled earlier than a with-replacement wait would suggest.
The second loss is starting the direct sum, position times the chance the first ace is there, which is correct but slow and easy to get wrong at a whiteboard. The gap argument gets there in one line.
What the interviewer asks next
- What is the expected position of the last ace?
- What is the expected number of cards between the first and second ace?
- How many cards do you expect to turn before the first spade?
