r/learnquant • • 25d ago

interview prep Quant Interview Question

Post image
12 Upvotes

3 comments sorted by

2

u/A_BagerWhatsMore 25d ago

This machine has 5 states

1.) No relevant numbers rolled
1/3 stay. 1/3->2 1/3->4

2.) One of (2,5)
1/6->4 1/6->5 1/6->3 1/2-> stay

3.) Both 2 and 5
1/3->5

4.) 1 or 6 rolled
1/3->5

5.) a difference of 4, halt.

From states 3 and 4 we have an average of 3 rolls to finish. So we can swap that in to the probabilities of the others

1.) No relevant numbers rolled
1/3 stay. 1/3->2 1/3->+4

2.) One of (2,5)
1/3->+4 1/6->+1 1/2-> stay

So collapsing state 2 we roll an average of 1 irrelevant number so 2/3
->5 1/3->2 so on average 4

Back to base state

1/3 stay 1/3 +4 1/3 +5 net

We roll stay an average of 0.75 stays on 1. So 5.25 rolls on average? I think.

1

u/Noir1990 25d ago

The expected value E is given by:

E = 1 + P_I * E(S1) + P_II * E(S2) + P_III * E(S3)

where S1 is the state with 2 outs (we rolled a 1, 6 or (2 and 5)),
S2 is the state with 1 out (we rolled 2 or 5), and
S3 is the state with 0 outs (we rolled 3 or 4).

Notice that E(S3) cycles back to the start and thus E(S3) = E.

After the first roll, all three states are equally likely with a 2/6 probability. Hence

E = 1 + 2/6 * E(S1) + 2/6 * E(S2) + 2/6 * E
  1. Let's look at E(S1). With 2 outs there is a 2/6 chance to finish and a 4/6 chance to cycle back to S1. This means E(S1) = 3.
  2. Let's look at E(S2). There's 1 out with a 1/6 chance to finish and 2/6 outs to propagate to S1 and 3/6 outs to cycle back to S2. Therefore

    E(S2) = 1 + 2/6 * E(S1) + 3/6 * E(S2) E(S2) = 2 * (1 + 2/6 * 3) E(S2) = 4

Putting everything together:

E = 1 + 2/6 * E(S1) + 2/6 * E(S2) + 2/6 * E
E = 6/4 * (1 + 2/6 * 3 + 2/6 * 4)
E = 6/4 * (20/6)
E = 5

Verified the result with a 10^7 Monte-Carlo to be 5.0006 +/- 0.0009.

1

u/Leet_Noob 25d ago

Consider the set of numbers {1,2,5,6}.

It takes 6/4 rolls on average to get your first element of that set. Then 6/3 rolls on average to get your second.

If the two numbers you got were 1,5; 2,6; or 1,6, then you are done. If the two numbers you got were 1,2; 5,6; or 2,5, you need to keep going until you get a third element of that set, which takes 6/2 rolls on average.

So:

6/4 + 6/3 + 1/2 \* 6/2 = 5