Hedge Funds puzzles, solved step by step
- Puzzles
- 100
- Traced to a firm
- 38
- Topics
- 14
- Hard
- 30
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?
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?
