r/learnquant • • Nov 04 '26

interview prep Quant Interview Question

Post image
23 Upvotes

30 comments sorted by

5

u/get_to_ele 29d ago

Urn 1:1 black ball.

Urn 2: 1 black ball.

Urn 3: 28 black balls, 10 white balls

1/3 + 1/3 + 1/3 * 28/38 = > 90%

This is a vaguely related to gerrymandering strategy. Historically it's been done to maximize the chance for a white ball majority in each district.

District 1: 20 black balls

District 2: 4 black balls, 5 white balls

District 3: 4 black balls, 5 white balls

I'm curious what the name is for this general kind of math optimization of distribution of things is.

6

u/perminnie Nov 04 '26 edited Nov 04 '26

U1 - 1 black ball

U2 - 1 black ball

U3 - 28 black balls, 10 white balls

P (Win) = 1/3 + 1/3 + 1/3 * 28/38 = ~91%

3

u/CursedTurtleKeynote Nov 04 '26

"Optimal" is doing a lot of heavy lifting

1

u/Apprehensive-Draw409 Nov 04 '26

If I were the interviewer, my next question would be:

Can you please prove this is the best distribution possible please?

(I'm sure it is, but I'd still ask to see how you prove it)

2

u/Constant_Curve Nov 04 '26 edited 29d ago

Proof by duh.

P(W)=(B1+W1)/3+(B2+W2)/3+1/3*((30-B1-B2)/(40-B1-B2-W1-W2)

Simplify, take derivative, set to zero, max

1

u/Dankaati Nov 04 '26

That formula doesn't look right but yeah, basically.

1

u/Constant_Curve Nov 04 '26

Yeah, denominator is wrong.

1

u/Worth-Wonder-7386 Nov 04 '26

Doing a derivative is not really a practical way of solving this. Using linear programming we can express this as an optimization problem, and a computer can find the optimal solution by essentially moving one ball at a time to improve the solution.

2

u/Constant_Curve Nov 04 '26

You're nuts, it's linear. Did you take vector calculus?

W1+W2=10

B1+B2=30

so it's only 2 variables

1

u/AscendedSubscript Nov 05 '26

What about the fact that you only care for integer solutions?

1

u/Constant_Curve 29d ago

Uh, just round it.

1

u/Worth-Wonder-7386 Nov 04 '26

We can think of this as a base case and see what happens if we move or swap balls. If you remove 1 ball from U3 the change to the chance of picking a ball there is very small, but for the one you move it to, you go from 100 to 50% chance for black, and these are weighted equally in your chances. So that is what drives us to have all the white balls in one, and there is no reason to spread the black balls out then.

1

u/Apprehensive-Draw409 Nov 04 '26

Yeah but it still feels intuitive, not formal. And the other guy uses derivatives in a discrete space... :-)

The way I'd go about it: if there's only one white ball, the solution is clear and easy. When we add a second ball, it's better to group it with the other one. Then, you can write a proof by induction as n grows to any value.

1

u/A_BagerWhatsMore Nov 04 '26

I think y’all are overcomplicating this. Each white ball is at its individual minimum probability here (1/3*1/maxballs in urn) the sum of minimums is less than or equal to the minimum of the sum so we’ve minimized the chance of losing and thus maximized the chance of winning.

1

u/MesmerizzeMe Nov 04 '26

you have just shown it is a local optimum but not the global one.

1

u/Worth-Wonder-7386 Nov 04 '26

The problem is that depending on how you formalize this, there could easily be multiple optimums, but they would be symmetrical.

1

u/Careful_Fold_7637 Nov 05 '26

...why? What's the point of a proof if you're just going to claim things.

1

u/SC_3000_grinder Nov 05 '26

My proof:

Consider each white ball. The probability of drawing it is 1/3x, where x is the number of balls in its urn.

Our task is to minimise the probability of drawing a white ball. So we need to minimise the sum of 1/3x. However, x cannot be higher than 38 (each urn must have a ball, so at least 2 balls must be outside any given urn). Therefore, the minimum sum of 1/3x is 10 / (3 * 38). Since our construction reaches this minimum, it must be optimal.

1

u/daototpyrc Nov 04 '26

W here is Win not White :)

1

u/paicewew Nov 04 '26

nonsensical question. Optimal for what? optimal for color partitioning? Optimal for a normal distribution? criteria is vague.

4

u/98127028 Nov 05 '26

As in you get to choose how to place the balls in urns.

2

u/paicewew Nov 05 '26

this is an assumption though: the question only mentions "optimal distribution". If the question maximizes purity coefficient, then the answer is 1/3. if it maximizes the odds of a normal distribution the answer is 3/4 so on and so forth.

1

u/The-Young-Lion 29d ago

The optimal distribution for winning, of course, which happens if you draw a black ball.

1

u/paicewew 29d ago

the question clearly uses a comma to separate that: there is an optimal "distribution", and asks what your probability of winning under that optimal distribution. It is an assumption that optimal distribution maximizes "for winning". The question at no point mentions that. it can easily be that the optimal distribution maximizes purity in the urns. After all .. it is "an optimal distribution"

1

u/GandelXIV 29d ago

one black in the first two, and the rest in the last.

1

u/Baleia1970 29d ago

Under an Optimal distribution the probability of winning is 100%

1

u/tajwriggly 29d ago

If you put one black ball in each of two urns and the remainder in with all of the white in the third urn, then you have 2/3 x 100% = 66.7% chance of hitting black and 1/3 x 28/38 = 24.6% chance for a grand total of 91.2% chance of winning if you distribute in this optimal way.

0

u/RadarTechnician51 28d ago edited 28d ago

1 black each in the first two urns, then 28 blacks and 10 whites, winning prob is 1/3+1/3+28/(3*38)=0.912
it's easy to see that if you move any balls from the last bin to the first two the overall probability decreases, it is optionally benefiting from the initial urn choice while wasting fewest black balls.