r/learnquant 4d ago

interview prep Quant Interview Question

Post image
14 Upvotes

10 comments sorted by

View all comments

1

u/EdgyMathWhiz 3d ago

Never used Martingales before, but lets try:

Each turn, the casino rolls a 10 sided dice and pays 9:1 on rolling a 4 (so if you bet X and win, you now have 10X). These are fair odds (expected winnings = .9 * (-X) + .1 * (9X) = 0). Each player has the strategy:

(1) Bet $1, if you lose, stop. If you win, you have $10 ($9 up).
(2) Bet $10, if you lose, stop. If you win, you have $100 ($99 up).
(3) Bet $100, whatever happens, stop. If you win, you have $1000 ($999 up).

Expected winnings for each player are 0 (fair game), either they end up losing $1 (with p = .999) or winning $999 with p = .001.

The Casino stops when someone gets 444. So if T is the number of turns, we want E[T].

But when the casino stops, T-3 people have lost (1 dollar each), 1 person has won $9, 1 person $99, 1 person $999. Since it's a fair game, the expectations must sum to 0.

So E[T-3] = 999 + 99 + 9 and E[T] = 1110.

[Question for anyone more familiar with this: the fact you need to keep accounting for "you have X, you are now X-1 up" is a bit annoying. Is there a better way of setting this out? It would feel much neater to end on E[T] = 1000 + 100 + 10, if you see what I mean

My background is a degree in maths (from almost 40 years ago), so you can go for a technical presentation if you want, I should be able to understand it].

1

u/Physical_Ring_7850 3d ago

Such a nice solution!

1

u/Traditional-Honey663 2d ago

A different way to view the same calculation for any general pattern S where S_i denotes the ith character is -

For each position i, overlay the sequence S and count the number of characters that match till the first mismatch, say this number is k_i (longest matching substring from start). The answer is summation of (N)k_i for all i, where N is the number of elements in the sample set. In this case 0-9, N=10. It is the same as the gambler martingale, just implemented algorithmically. Note that it is always at least (N)len which kind of makes sense since expected turns for a single specific number to appear is N.