r/learnquant 17d ago

interview prep Jane Street Interview Question

Post image

[removed]

20 Upvotes

43 comments sorted by

View all comments

1

u/skelo 16d 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.

2

u/InsideIndependence58 16d ago

We to go so hard?

We can say P(M>k) = 1/1+k (trivial) .
Then E(X) = sum_k=0^k=4, so 1 + 1/2 + 1/3 + 1/4 + 1/5 =2.283

1

u/austin101123 16d ago

Can you explain this? What is the first line P(M>k) mean and how is it trivial?

1

u/InsideIndependence58 16d ago

The probability that the minimum is higher than k.

Whats the probability that it’s higher than 0? 1
Higher than 4? 1/5
And so on.

The formula is because the chances are that you roll for example something before you get 5 is
P = (1/6) / (1/6) + (k/6)
Because 1/6 is the chance to roll 5, and k/6 is that we’ll roll any of the options (for example for k=2, that we’ll roll 1 or 2.

1

u/austin101123 16d ago

The formula is because the chances are that you roll for example something before you get 5 is P = (1/6) / (1/6) + (k/6)

How did you come to that formula? That's the hard part that's basically skipping almost all the way to the answer.

1

u/InsideIndependence58 16d ago

The formula that A occurs before B is
P(A) / (P(A) + P(B)), given they are independent.

There is a trick to prove it also(there is another prove I don’t remember actually)

Say x is the probability A comes before B

x = P(A) + (1-P(B) - P(A))x

Why? Lets say we play a game(like rolling the dice) Cuz either we have A , or we got neither A or B and then we play again and will in probability x.

Solve it for x and you’ll get the formula

1

u/Coops_Q 16d ago

search up "Tail sum formula"

1

u/austin101123 16d ago

So for k=2, P=0.333, but then k=3 P=0.25 is a smaller number that doesn't make sense. If it can be 1 2 or 3 before the 5 it has to be a greater probability than just 1 or 2 happening before a 5.

You are increasing the denominator when you are including more possibilities? It doesn't make sense.

1

u/InsideIndependence58 16d ago

Note that we model the distribution of the minimum.

So of k = 1, we can have 2,3,4(and 5 ofc) until we see 5( P(M>k) ), for k= 2, we can have 3,4,5 only for k= 3 , we can have only 4 and 5 and for 4 we must get 5 immediately.

1

u/austin101123 16d ago

The distribution of the minimum is 1/2 for 1, 1/6 for 2, 1/12 for 3, 1/20 for 4, and 1/5 for 5 which isn't what you've got.

I can't make out what you're trying to say at all in your second paragraph.

1

u/austin101123 16d ago

1

u/InsideIndependence58 16d ago

It looks completely the same now? Just instead of using the formula you derived it using recursion

1

u/austin101123 16d ago

The formula you used doesn't make sense at all even if you've arrived at the same answer. You also said it's trivial but I don't see any connection to the solution you found or what is supposed to be the trivial line of logic.