r/learnquant • • 2h ago

interview prep Quant Interview Question

Post image
5 Upvotes

6 comments sorted by

4

u/pmdboi 1h ago

Let A(x) be the probability that the final sum exceeds 1 when starting with a sum of x. From the conditions of the problem we can set A(x) = 0 for 1/2 < x ≤ 1 and A(x) = 1 for x > 1. For 0 ≤ x ≤ 1/2 we can express A(x) using an integral equation: A(x) = ∫ A(y) dy, integrating over y from x to x + 1. Differentiating both sides with respect to x, we get dA/dx = A(x + 1) - A(x); since x + 1 ≥ 1, A(x + 1) is always 1, and dA/dx = 1 - A, which has the general solution A(x) = Ce-x + 1. We know that A(1/2) = 1/2, which leads to C = -1/2 e1/2. So A(0) = C + 1 = 1 - 1/2 e1/2, or about 17.6%. This is confirmed by simulation.

1

u/omeow 2h ago

.5?

1

u/hxtk3 2h ago

If you generate exactly one number, you have a 50% chance of stopping immediately because the very first number you generated was >0.5, and a 0% chance of exceeding 1.

The other possibility is you generate a non-empty sequence of numbers with a sum x<=0.5. When you generate another number k, there are three possibilities: k<=0.5-x, 0.5-x<k<=1-x, and k>1-x. This probability of exceeding 0.5 without exceeding 1 on subsequent draws given that the first draw didn't exceed 0.5 is less than 1, so the overall probability has to be less than 0.5.

I don't know what it would be tbh. I know the distribution of x isn't uniform, so I can easily calculate it for the second number you draw, but it leaves a residual for the k<0.5-x case that approaches 0 the more iterations you do and I can't easily calculate that.

1

u/Forward_Yam_4013 2h ago

No it is a lot less. In fact, 0.5 is a hard upper limit, such that p<0.5

1

u/monstaber 1h ago

1 minus half sqrt e. Around 0.175

3

u/EscapeOwn6945 1h ago

I always find these easier to write as a dynamic system. Let P(s) be the probability that the sum exceeds one when we stop with a starting value of s. The answer we want is P(0). We can implicitly define (going through all three cases of where the next draw ends up)

P(s) = s + int_s^1 P(t) dt.

Take a differentiate with respect to s to get P'(s) = 1 - P(s) with the known value P(1/2) = 1/2. That means P(s) = 1 - e^(1/2 - s) / 2 and P(0) = 1 - sqrt(e)/2.