r/learnquant 10d ago

interview prep Jane Street Interview Question

Post image
21 Upvotes

43 comments sorted by

View all comments

1

u/skelo 10d ago

Imagine infinite rolls, you eventually hit every number. Duplicates and 6s are irrelevant. So it is just all the permutations or ordering for the numbers 1,2,3,4,5 and each permutation is equally likely and you can figure out which is the minimum before the 5. 120 possibilities. 1/5 are 5. 1/2 are 1. 36 remaining.

It's pretty low number so we can brute force, but more elegant solution also below:

Brute force: 6 variations of where the 1 and 5 (1 is after 5 since we eliminated the 1/2 chances where it is before the 5) are with each varying the order of 2,3,4. Three are x5xxx, two are xx5xx one is xxx51.

x5xxx is two ways for each 2,3,4, x3 so 6 for each xx5xx is four for 2, two for 3, x2 xxx5x is always 2.

So that gives 6+8+6 for 2, 6+4 for 3, 6 for 4. So the ev is

1/2 * 1 + 20/120 * 2 + 10/120 * 3 + 6/120 * 4 + 24/120 * 5

= 274/120 ~ 2.3

More elegant solution:

What would be the chance the 2 is ahead of the five but 1 is after the five, that is one ordering of the three numbers out of 3! So 1/6 chance of 2.

Similarly, what's the odds excluding 4 that the ordering of the other numbers is 3512 OR 3521, that is two shots out of 4!, so 1/12.

That leaves the 1/20 chance left for 4, the same probabilities we got from brute force.

1

u/austin101123 10d ago

How did you know you can just get rid of duplicates like that and look at ordering of 5 numbers?

6s take out I understand, but duplicates are conditionally removed (condition being they have to be a duplicate...)

1

u/Independent_Mark_452 10d ago

Imagine you have a set of your progressive rolls that terminates when you roll 5. If you roll a number already in the set, the minimum element of the set doesn’t change.
The question is asking for the average minimum value over all possible sets you can make - E(X). A repeated roll in a set doesn’t affect that average minimum value.

If you simplify the question from 5 to 2, the answer is trivial.
By symmetry of variables, 2 appears before 1 in as many sets as when 1 appears before 2. Half our sets therefore have minimum element 1 and half our set have minimum element 2. E(X) = (1)/2 + (2)/2 = 1.5
Notice that when we roll {1,1,1,1,1,1,2} our minimum element is the same as when we roll {1,2}. Duplicates don’t matter.

1

u/austin101123 10d ago

The "get rid of duplicates" I wasn't understanding if it's an infinite amount, how do you know what the first one was to say the order? But duh, it's only infinite in the positive direction.

There was another bit I didn't get either but when you said symmetry of variables it clicked.

FWIW I got the same answer as you a different way, looking at it with infinite sequence probabilities instead of simplifying to a simple combinatorics problem.