# How can one maximise a probability?

Take the following problem:

You have 100 balls (50 black balls and 50 white balls) and 2 buckets. How do you divide the balls into the two buckets so as to maximize the probability of selecting a black ball if 1 ball is chosen from 1 of the buckets at random?

If you put 1 black ball in one bucket and all the other balls in the other bucket then you will maximise the probability of picking a black ball, since there is a 50% chance of picking either bucket, so the probability becomes $$P(B)=(0.5\times1)+\Big(0.5\times \frac{49}{99}\Big)=0.75=75\%.$$ How can this be expressed mathematically? I.e. how does one maximise $$P(B)=\frac{0.5N_{B1}}{N_{B1}+N_{W1}}+\frac{0.5N_{B2}}{N_{B2}+N_{W2}},$$ where $N_{B1}$ is the number of black balls in the 1st bucket, $N_{W1}$ is the number of white balls in the 2nd bucket and so on.

Is there a general method for maximising probabilities? Do we have to somehow differentiate?

• It should be $49/(50+49)=49/99$ in your first line of calculations. – Jimmy R. Oct 25 '16 at 9:48

To simplify notation, let $x=N_{B_1}$ and $y=N_{W_1}$. Then $N_{B_2}=50-x$ and $N_{W_2}=50-y$, and your second line becomes \begin{align}p(x,y)&=\frac12\cdot\frac{x}{x+y}+\frac12\cdot\frac{50-x}{50-x+50-y}=\frac12\cdot\frac{x(100-x-y)+(50-x)(x+y)}{(x+y)(100-x-y)}\\[0.3cm]&=\frac{-x^2+75x-xy+25y}{(x+y)(100-x-y)}\end{align} Now, this is a function of two variables, which you want to maximize and this can be done by differentiation. However, recall that $x,y$ take only discrete values, $x,y=0,1,2,\dots 50$.
• @user428487 Not really clever here, so I can only see a "clever way" to differentiate: Assume that somehow, you have shown that $y=0$ in the optimal solution. Then, $x=0$ is excluded as an optimal solution and for $x\ge1$, $p(x,y)$ reduces to $$p(x,y)=\frac12\left(1+\frac{50-x}{100-x}\right)$$ which is easily shown to be decreasing in $x$. Hence, the optimal $x=1$. Thus, it remains to show that $y=0$ in the optimal solution. This points to differentiating first with respect to $y$ and showing that the first partial derivative (with respect to $y$) is decreasing in $y$. – Jimmy R. Apr 24 '18 at 7:55