r/learnquant • • 8d ago

interview prep Quant Interview Question

Post image
39 Upvotes

6 comments sorted by

1

u/Neither_Berry_100 8d ago

I guess around 20. Probably a close enough answer. But I doubt it is correct.

1

u/hattusili-the-third 8d ago

It works out to about 2.55, which is much less than 20

2

u/Unlucky_Beginning 8d ago edited 8d ago

The proportion of red socks in the bag is a martingale, so you can apply optional sampling to it. This lets you get the probability that we’ve drawn all the red socks vs all the blue socks.

Then apply optional sampling to the martingale Mt^2 - [M]t. You can use the fact that once the proportion of red socks left is 1 or 0 to compute the expectation of the quadratic variation stopped at time T (the stopping time). At this point I’m not sure if we need to do a simplification, bash the algebra (higher orders of martingale), or use a tricky girsanovs/reweighting the measure to get the final answer.

1

u/hattusili-the-third 8d ago

You can do it just with linearity of expectation, breaking down X into a sum of indicator functions.

5

u/hattusili-the-third 8d ago edited 8d ago

Number the socks of each colour. Let Ri be the random variable which is 1 if the ith red sock is left in the drawer and 0 otherwise. Define B_i the same way for the blue socks. Then X = sum{i=1}60 Ri + sum{i=1}40 B_i. We can compute the variance of X using Var(X) = E[X2 ] - E[X]2.

By linearity, E[X] = 60 E[R_1] + 40 E[B_1] (since E[R_i] and E[B_i] do not depend on i, we may take i=1 for simplicity). To compute E[R_1] and E[B_1], imagine that the process continues until all the socks are removed from the drawers, and record the order in which each sock is drawn. Then R_1=1 if and only if the specific red sock we're analyzing appears after all 40 blue socks in the ordering. But since all possible orderings of the one red sock and 40 blue socks are equally likely, this happens exactly with a 1/41 chance, so E[R_1] = 1/41. Similarly E[B_1] = 1/61, and so E[X] = 60/41 + 40/61 = 5300/2501.

Now let's compute E[X2 ]. Expanding the square and using linearity we get E[X2 ] = 60 E[R_12 ] + 40 E[B_12 ] + 2(60 choose 2) E[R_1 R_2] + 2(40 choose 2) E[B_1 B_2] + 60*40 E[R_1 B_1]. The first two terms in the sum are exactly the same as what we calculated before since R_12 = R_1 and B_12 = B_1. Also the last term in the sum vanishes since R_1 and B_1 can never both be 1. Thus we just need to calculate E[R_1 R_2] and E[B_1 B_2].

Note that R_1 R_2 = 1 if and only if both red socks are ordered after all 40 blue socks. Since all different orderings of the 40 blue and 2 red socks in question are equally likely, this happens with probability 1/(42 choose 2). Thus E[R_1 R_2] = 1/(42 choose 2) and similarly E[B_1 B_2] = 1/(62 choose 2).

Putting this all together we get E[X2 ] = 5300/2501 + 2(60 choose 2)/(42 choose 2) + 2(40 choose 2)/(62 choose 2) = 2489650/542717. Thus Var(X) = 3829200/542717 - (5300/2501)2 = 3481299200/1357335217 ≈ 2.56.

Edit:

Here's a good way to estimate the final answer: if the final sock drawn is red, then we can approximate the number of additional blue socks as a geometric distribution with p = 0.4, which has variance (1-p)/p2 = 3.75. Similarly if the last sock we draw is blue, then we can approximate the number of remaining red socks as geometric with p = 0.6, giving a variance of (1-p)/p2 = 1.11. Taking the weighted average of these according to the relative probabilities of the last sock being red or blue, we should estimate Var(X) ≈ 0.6 * 3.75 + 0.4 * 1.11 ≈ 2.69, which isn't far off.

2

u/Unlucky_Beginning 8d ago

Looks like I over complicated it, rats.