# Maximise conditional probability of urns

I have two urns, urn $1$ contains $k$ white balls and $l$ red balls, urn $2$ contains $n - k$ white balls and $n -l$ red balls. I have the total probability

$P($ "white ball is drawn" $) = \frac{k}{k + l} \frac{1}{2} + \frac{n - k}{2n - (k + l)} \frac{1}{2}$

and I would like to find $k$ and $l$ such that this probability is maximal. How can I do that? I tried to set the derivative of $P$ with respect to $k$ zero but this gets awfully complicated. Is there a better way to do this? Many thanks for your help!

If you set $m = k+l$, then the probability of selecting a white ball can be expressed as $$P_w = \frac{k}{2m} + \frac{n-k}{2(2n-m)} = \frac{k(2n-m) + (n-k)m}{2m(2n-m)} = \frac{2k(n-m) + nm}{2m(2n-m)}.$$ This is invariant under $(k,m)\rightarrow(n-k,2n-m)$ (which just exchanges the urns), so we can assume $m \le n$ with no loss of generality. If $m=n$, we have $P_w = 1/2$. For $m<n$, the probability is clearly maximized by taking $k$ as large as possible, which is $k=m$ (so $l=0$). In that case, $$P_w = \frac{2m(n-m) + nm}{2m(2n-m)} = \frac{3n-2m}{4n-2m} = \frac{3}{4} - \frac{m}{4(2n-m)}.$$ This is a decreasing function of $m$, so $m$ should be taken as small as possible, which is $m=1$, in which case $$P_w = \frac{3}{4} - \frac{1}{4(2n-1)}.$$ This is at least $1/2$ for all $n\ge 1$, so the answer $(k,l)=(1,0)$ always gives the best odds of drawing a white ball... probability $P=1$ if the left urn is picked, and just under $P=1/2$ if the right urn is picked, for an overall probability of just under $3/4$.

Hint: First try with the same number of black and white balls, as it will lead you to the solution in the more general case. Note that if you have the same number of balls in each urn, the probability is 1/2 regardless of the distribution. So to get the probability away from 1/2 it needs to be unbalanced. Also if each urn is equally split, the probability will be 1/2 regardless of how many balls are in each urn. So imagine transferring a black ball from one urn to the other and see what it does to the probability. There is a solution that is easy to convince yourself is optimal once you see it.

• Imagine there are lots of balls, equal numbers black and white. This way you get 1/2 chance you select urn 1 (and so will win) and if you select urn 2 you have (almost) 1/2 chance of winning. So your total chance is (almost) 3/4. You get so much chance of winning for so few (one) white balls, how can anything be better? Clearly not rigorous, but many find it convincing. – Ross Millikan Feb 10 '11 at 18:46

Hint: change variables.

Call $b_1 = l_1 + k_1$ the balls in urn 1, $b_2 = l_2 + k_2$ the balls in urn 2. We may assume $l_1 , l_2$ are fixed, and that $b_1,b_2$ are our variables, subject to the restriction $b_1 + b_2 = 2n$

You want then to maximize

$\displaystyle \frac{b_1-l_1}{b_1}\frac{1}{2} +\frac{b_2-l_2}{b_2}\frac{1}{2}$

which is the same that minimize

$\displaystyle g(b_1,b_2) = \frac{l_1}{b_1} + \frac{l_2}{b_2}$

(with the restriction $b_1 + b_2 = 2n$)

From this, you can continue (Lagrange multipliers or whatever).

FYI, I get (assuming real values)

$\displaystyle \frac{b_1^2}{l_1} = \frac{b_2^2}{l_2}$

which leds to

$\displaystyle k_1 = \frac{2n}{1+\sqrt{l_2/l_1}}-l_1$

• Thanks. I'm supposed to get $k=1, l=0$, how do you get that from what you wrote? I think you can assume natural values instead of reals because balls should occur in natural numbers ; ) – Rudy the Reindeer Feb 10 '11 at 18:02
• Well, I assumed you only have k variable, l fixed. – leonbloy Feb 10 '11 at 18:33