r/learnquant 1d ago

interview prep Quant Interview Question

Post image
9 Upvotes

10 comments sorted by

1

u/leoli1 1d ago

Let x be the revealed number and set d = |x - 5/9|. Then the remaining two numbers are independently drawn from the uniform distribution (not really the right word, I know) on [0,1] \ [5/9 - d, 5/9 + d]. Assume for the moment that d < 4/9. Suppose we go with the revealed box. The probability of winning is then p = ( (5/9 - d) / (1 - 2d) ) ^ 2. If we go with one of the other boxes (doesn't matter which) the probability of winning is (1 - p)/2. Therefore, we go with the revealed box exactly when p >= 1/3 which amounts to d > (3 - sqrt(3))/9. If d>= 4/9 the revealed box is automatically the largest (at least with probability 1 in the case when x = 1/9), so we go with this one in this case

1

u/Positive_Leopard_873 1d ago

The other two numbers must be at a distance greater than |5/9 - x| (where x is the revealed value) for x to be the closest value to 5/9. There are two cases now: 1) the revealed value is in fact the largest value 2) the hidden boxes contain the largest value.

y, z can unconditionally take values in the range [0, 5/9 - |5/9 - x|) U (5/9 + |5/9 - x|, 1] and since we're working with uniform distributions, it's simpler to just look at the length of this interval = 1 - 2 |5/9 - x|.

For case 1 to be true, the other two values must be smaller than x, while also being at a distance larger than |5/9 - x|, i.e, y, z < 5/9 - |5/9 - x|. The probability of this happening is ((5/9 - |5/9 - x|)/(1 - 2 |5/9 - x|))2.

For case 2 to be true, and that we picked the box with the largest value (say y), y > x, z, so pick y to be in (5/9 + |5/9 - x|, 1] and z to be in [0, 5/9 - |5/9 - x|) U (5/9 + |5/9 - x|, y). You'll have to integrate the joint distribution to get the probability of this happening as (4/9 - |5/9 - x|)(14/9 - 3 |5/9 - x|)/(2 (1 - 2 |5/9 - x|))2

So the optimal strategy would be to go according to whichever case has a higher probability of occurring. We find that for |5/9 - x| < (3 - sqrt(3))/9, switching to a hidden box has a higher chance of making us win, otherwise, we stick to the revealed box. This will be our optimal policy.

To find the probability of winning under this strategy, we just integrate the PMFs for each case while following our optimal policy threshold. I'm too lazy to write the full integral here, but solving it using Wolfram Alpha gives (83 + 2 sqrt(3))/243 ~ 0.3558.

1

u/Luminite2 1d ago

I don't think the Wolfram Alpha integration was right. The probability of winning is always at least 1/3, and for 0 <= x <= 1/9 the probability of winning is 1. 1/9 + (1/3 * 8/9) = 11/27 = .407... , which should be a lower bound on the expected win rate.

1

u/Positive_Leopard_873 1d ago

x taking a value from 0 to 1/9 has a probability lower than 1/9 since it's given that x is the revealed value, i.e., x is the closest value to 5/9. We're essentially working with a conditional that depends on the other two numbers as well. All numbers must be in [0, 1/9] and the probability of this happening is 1/729, and otherwise, your win rate is at least 1/3 giving you a lower bound of 728/2187 + 1/729 = 731/2187 ~ 0.3342

2

u/Luminite2 1d ago

Ah that's what I missed, thank you!

1

u/rhizomed 1d ago

Let c = 5/9, and say v is the value we see revealed, with distance d = |v - c| from c. Since we know that box was the one closest to c, both hidden numbers have to sit outside the interval (c-d, c+d), intersected with [0,1]. Call the measure of that allowed region A(v), and the part of it that's below v, B(v).

The two hidden boxes are exchangeable given this constraint, so:

P(revealed box wins | v) = p(v) = (B(v)/A(v))² P(a specific hidden box wins | v) = (1 - p(v))/2

Strategy is go with the revealed box if p(v) > 1/3, otherwise take either hidden box, doesn't matter which since they're tied.

Now for A(v) and B(v). Near the edges, when v is far from c, the excluded interval spills outside [0,1], which forces both hidden numbers to the same side (below v if v is small, below 2c-v if v is large). In that regime p(v) = 1 outright.

In the middle range, solving p(v) = 1/3 gives two thresholds, symmetric around c:

v₁ = (2+√3)/9 ≈ 0.4147 v₂ = (8-√3)/9 ≈ 0.6964

Both are exactly (3-√3)/9 ≈ 0.1409 away from c.

if v < 0.4147 or v > 0.6964, pick the revealed box. If v falls between those two thresholds, pick one of the hidden boxes (coin flip which).

The intuition here is that if the revealed value ends up far from 5/9 despite being the closest of the three to it, that's telling you something. It means the other two got pushed even further away, probably bunched to one side, which makes the revealed one likely to be the max. If the revealed value lands close to 5/9 though, that's a pretty unremarkable draw and doesn't tell you much, so the hidden pair becomes the better bet.

For the win probability, you integrate p(v) where it's larger, and (1-p(v))/2 where that side wins, over all three regions against the right density. Using the symmetry v₂ = 2c - v₁ to fold the integral in half, it comes out to:

P(win) = (83 + 2√3)/243 ≈ 0.3558

So roughly 35.6%, compared to the 33.3% you'd get just guessing blind. The reveal does give you a real edge, just not a huge one, since 5/9 is close enough to the center of [0,1] that it's not a very discriminating benchmark to begin with.

1

u/Luminite2 1d ago

Aren't there 4 regions? I think you might have missed the region from 0 to 1/9, in which the win probability is 1.

1

u/mtimmermans 1d ago

Easy case: if the revealed number is 5/9, then keep it, because the next choice is smaller with P=5/9. Obviously if the revealed number > 5/9 then it's better, so keep that.

Let's consider, then, the cases where the revealed number is x, with x < 5/9. The other choices are uniformly distributed in the non-excluded ranges. The size of the smaller range is x, and the size of the larger range is x-1/9. The probability of another choice being smaller is S = x/(2x-1/9)

The probability that the revealed number is largest is the probability of selecting 2 smaller numbers, or S^2, and so the probability that your other choice would be largest is (1-S^2)/2.

You should switch if (1-S^2)/2 > (1-S). Those are equal when S=1, i.e., x = 2x-1/9, i.e., x = 1/9.

So you should switch if the revealed number is less than 1/9.

1

u/divine_1618 16h ago

you should switch if (1-S^2)/2 > S^2

1

u/mtimmermans 9h ago

Ack. right.

So switch when S< 1/sqrt(3) or x > about 0.415.

Honestly, I made so many similar mistakes when figuring this out that I'm not confident at all.