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$.