This is a rehash of this question (and probably the intent of this, and several other similar questions), but I'd like:
- a more detailed answer that builds from the simplest cases to potentially higher order applications and more references to explanations, if possible.
- a proof of the optimality of the so-called gerrymandering solution.
So here is a complete statement of the problem:
Suppose that you are given 50 each of red and blue balls, and two urns. You place the red and blue balls in the urns (so that each is nonempty, and all the balls are allocated to some urn). Then you pick a jar at random and pick a ball at random. The objective is to distribute the red and blue balls in each of the urns so that the probability of picking a red ball is maximized.
The so-called gerrymandering solution is given after the break below, and I am wondering if there is a systematic way of arriving at this solution, other than guesswork.
Attempt 1
My first thought was to use calculus on this problem, so that if I denote the jars A and B, and denote the tuple $(x, y)$ as the number of red and blue balls in jar A. The the solution $(x^*, y^*)$ is the solution to the first-order conditions. (This is probably a red herring, since only nonnegative integer solutions are valid.)
$ \begin{alignat}{2} &&p(x, y) &= \frac{1}{2}\left(\dfrac{x}{x+y}+ \dfrac{50-x}{100-x-y}\right) \\[1em] &&\left. \dfrac{\partial p(x, y)}{\partial x}\right|_{(x,y)=(x^*, y^*)} &= 0 \\[1em] &\implies\quad&\dfrac{2x^*+y^*}{(x^*+y^*)^2}-\dfrac{150-2x^*-y^*}{(100-x^*-y^*)^2} &=0 \\[1em] &&\left. \dfrac{\partial p(x, y)}{\partial y}\right|_{(x,y)=(x^*, y^*)} &= 0 \\[1em] &\implies\quad& \dfrac{-x^*}{(x^*+y^*)^2} +\dfrac{50-x^*}{(100-x^*-y^*)^2} &= 0 \end{alignat} $
This involves finding the solution of cubic equations (which I am sure can be done, with the help of CAS, but it is not obvious that this yields the gerrymandering solution (does it?)). Is this the right way to think about the problem? What is?
Attempt 2
Note however that the objective function is closed-form, so can easily be graphed, and then the solution becomes clear.
The gerrymandering solution
You place one red ball and no blue balls in one urn and all the other balls in the other urn. This leads to the probability of picking a red ball $>\tfrac{1}{2}$.