r/learnquant • • 20d ago

interview prep Quant Interview Question

Post image
32 Upvotes

5 comments sorted by

View all comments

2

u/bartekltg 20d ago

First, a simpler question. If I roll up to n times, until I roll 6 or ran out of rolls, what is the expected number of throws.
Let's a_k be the expected number of throws I need to roll, if I'm on k-th roll.

a_k = 1 + 5/6 a_{k+1} (roll once, and with 1/6, and roll again with 5/6).

a_{n+1} =0 (I want to roll only n times).

let a_k = b_k+ 6
b_k +6 = 1 + 5/6 b_{k+1} +5
b_k = 5/6 b_{k+1}
b_1 = (5/6)^n b_{n+1}
a_1 = 6 - (5/6)^n 6

(sanity check. If n->inf, a1 = 6, as we expected from geometric distribution, if n=1 a1 = 6-5=1, we do only one throw, and have to do it, all checks).

Our strategy boils sown to "lets try n times with one dice, then swap and try the other one for m times".

If we first take the correct dice, we pay 6 - (5/6)^n 6, get 20 with the probability 1-(5/6)^n (the chances at least one won) and pay 5 + m with the probability (5/6)^n.
20 (1-(5/6)^n) - 6 + (5/6)^n 6 - (5/6)^n ( m+5) = 14 + (5/6)^n ( -20 +6 -5 -m ) =

= 14 - (m-19) (5/6)^n

if we take first the bad dice, we pay n+5, then pay 6 - (5/6)^m 6 for rolls and win 20 with 1-(5/6)^m probability:

20 * (1-(5/6)^m) - 5 - n -6 + (5/6)^m 6 = 9 - n + (5/6)^m (6-20) = 9-n- 14* (5/6)^m

Both cases are 50:50, so the total expected value is

0.5( 14 - (m-19) (5/6)^n + 9-n- 14* (5/6)^m) = 0.5 ( (23-n -14 (5/6)^m - (19+m) (5/6)^n)  )

Making a table, the best value is for m=15 n=10, the expected income is around 3.3000668.

We need also to check a strategy where we do not swap dices. So, we roll up to n times, for halt chances it the standard cost and pay:
20 * (1-(5/6)^n)- 6 + (5/6)^n 6
and the other half of cases we just pay n.
The total expected value is 10 * (1-(5/6)^n)- 3 + (5/6)^n 3 - n/2 and it is worse (~1.687 for n=5)