Chapter 4.1, Problem 23
You are given two urns and fifty balls. Half of the balls are white and half are black. You are asked to distribute the balls in the urns with no restrictions placed on the number of either type in an urn. How should you distribute the balls in the urns to maximize the probability of obtaining a white ball if an urn is chosen at random and a ball drawn out at random? Justify your answer.
Call the two urns I and II. In I, place one (1) white ball. In II, place twenty-four (24) white balls and twenty-five (25) black balls. The probability of choosing a white ball is now
\[ P(I)=\frac{1}{2},P(II)=\frac{1}{2}\\ P(B|I)=0,P(W|I)=1\\ P(B|II)=\frac{25}{49},P(W|II)=\frac{24}{49}\\ \] So, \[ P(W)=P(I)\cdot P(W|I)+P(II)\cdot P(W|II)\\ P(W)=\frac{1}{2}\cdot1+\frac{1}{2}\cdot\frac{24}{49}\\ \approx .745\\ P(B)=P(I)\cdot P(B|I)+P(II)\cdot P(B|II)\\ P(B)=\frac{1}{2}\cdot0+\frac{1}{2}\cdot\frac{25}{49}\\ \approx .255 \]
While I cannot say that this gives the absolute best odds, it is a local maximum. If one black ball is moved from II to I, the odds of drawing a white ball fall to \(\frac{1}{2}\). Likewise, if a white ball is moved from II to I, the odds of drawing a white ball from I stay at 1, while the odds of drawing a white ball from II fall to \(\frac{23}{48}\). Finally, moving the white ball from I to II reduces the odds of drawing a white ball to \(\frac{1}{4}\), as there is now a \(50\%\) chance of not having any balls to draw.
I tested it out with (incredibly inefficent) code. It shows emperically that this arrangement is very likely the best one.
OneSample<-function(){
a<-0
for(WhiteUI in c(0:25)){ #number of white balls in urn1
for(BlackUI in c(0:25)){ #number of black balls in urn1
UrnNo<-sample(1:2,1) #choosing the urn number
if(UrnNo==1){
if(WhiteUI == 0 & BlackUI==0){ #if it's empty, then we will not draw a white ball
a<-cbind(a,0)
}else{
BallNo<-sample(1:WhiteUI+BlackUI,1) #randomly chooses a number between 1 and the number of balls, white balls are the lower numbers, black balls are the higher ones
if(BallNo>WhiteUI){
a<-cbind(a,0)
}else{
a<-cbind(a,1)
}
}
}else{
if((25-WhiteUI) == 0 & (25-BlackUI)==0){ #same as the first part of the if statement, except that now I'm doing 25-the number of balls in Urn I, as these are the ones left over
a<-cbind(a,0)
}else{
BallNo<-sample(1:(50-WhiteUI+BlackUI),1)
if(BallNo>(25-WhiteUI)){
a<-cbind(a,0)
}else{
a<-cbind(a,1)
}
}
}
}
}
a<-a[2:677]#remove the initial 0
return(a)
}
A<-data.frame(t(rep(0,676))) #creating a data.frame with 676 columns
for(i in 2:4000){
A<-rbind(A,OneSample()) #sampling each case 3999 times
}
sA<-colSums(A) #adds up the number of times each arrangement got a white ball over the 3999 trials
max.col(t(sA)) #tells us which arrangement got a white ball the most times
## [1] 27
This code takes a long time to run, so I only ran it twice. The values of sA are the number of times a white ball was found after 3999 trials of choosing randomly from each urn. The maximum is found in the 27th iteration, which is 1 white ball in Urn I and all the other ones in Urn II.