Open Side Menu Go to the Top
Register
Balls and bins Balls and bins

09-27-2022 , 09:06 PM
There are 5 green balls and 10 red balls, initially placed into bins A and B as follows:
Bin A has 1 green ball.
Bin B has the remaining 14 balls.

We randomly select 2 balls from Bin B and transfer them to Bin A.
Next, we randomly select 1 ball from Bin A and transfer it to Bin B.

After those two steps, if we a randomly select a ball from Bin B, what’s the probability of a green?
Balls and bins Quote
09-28-2022 , 06:49 AM
I have two methods in mind to tackle this problem. As I am writing this post, I do not know whether these two methods will yield the same result, but I think the results will be the same.

1st method: Expected value

Stage 1
  • Bin A has 1G + 0R
  • Bin B has 4G + 10R
Stage 2
The expected number of green and red balls transferred to Bin A from Bin B are 0.57 and 1.43, respectively.
After the balls are transferred, the expected number of balls in the bins are as follows:
  • Bin A has 1.57G + 1.43R
  • Bin B has 3.43G + 8.57R
Stage 3
The expected number of green and red balls transferred to Bin B from Bin A are 0.52 and 0.48, respectively.
After the ball is transferred, the expected number of balls in the bins are as follows:
  • Bin A has 1.05G + 0.95R
  • Bin B has 3.95G + 9.05R
The probability of randomly selecting a green ball from Bin B after these stages is 3.95/13 = 30.4%


2nd method: Case by case

1st transfer
The balls transferred from Bin B to Bin A can be:
  • a) 2R + 0G with a probability of 10/14 * 9/13 = 49.5%
  • b) 0R + 2G with a probability of 4/14 * 3/13 = 6.6%
  • c) 1R + 1G with a probability of 10/14 * 4/13 * 2 = 43.9%;
which means Bin A will have:
  • a) 1G + 2R with a probability of 49.5%
  • b) 3G + 0R with a probability of 6.6%
  • c) 2G + 1R with a probability of 43.9%
and Bin B will have:
  • a) 4G + 8R with a probability of 49.5%
  • b) 2G + 10R with a probability of 6.6%
  • c) 3G + 9R with a probability of 43.9%

2nd transfer
The ball transferred from Bin A to Bin B can be:
  • If a) is the case for the first transfer, 33.3% G and 66.7% R.
  • If b) is the case for the first transfer, 100% G and 0% R.
  • If c) is the case for the first transfer, 66.7% G and 33.3% R.
Therefore, the probability distribution of Bin B's ball contents after these two transfers is:
  • a1) 5G + 8R with a probability of 49.5% * 33.3% = 16.5%
  • a2) 4G + 9R with a probability of 49.5% * 66.7% = 33.0%
  • b1) 3G + 10R with a probability of 6.6% * 100% = 6.6%
  • b2) 2G + 11R with a probability of 6.6% * 0% = 0%
  • c1) 4G + 9R with a proability of 43.9% * 66.7% = 29.3%
  • c2) 3G + 10R with a probability of 43.9% * 33.3% = 14.6%
Aggregating a2-c1 and b1-c2, we have three sets of possibilities (b2 is an impossible state):
  • 1) 5G + 8R with a probability of 16.5%
  • 2) 4G + 9R with a probability of 33.0% + 29.3% = 62.3%
  • 3) 3G + 10R with a probability of 6.6% + 14.6% = 21.2%
As a result, the probability of picking a green ball from Bin B becomes 5/13 * 16.5% + 4/13 * 62.3% + 3/13 * 21.2% = 30.4%.

Looks like both methods yielded the same result and the second method turns out to be quite inefficient.
Balls and bins Quote
09-28-2022 , 09:29 AM
Yup well done, the exact answer is 83/273. Recognizing that the probability is the same as E(# of green drawn) allows us to make use of linearity of expectation, as Numen's first solution did. Had the final step been to draw two balls, that shortcut wouldn't have been available because the probability would no longer be equivalent to an expectation.
Balls and bins Quote
09-28-2022 , 10:01 AM
To elaborate on heehaww's remark, I will use the same methods I previously used for the altered version (probability of at least one green ball if two balls are selected from Bin B after two transfers). I will skip the intermediate steps.

1st method: Expected value

Stage 3
  • Bin A has 1.05G + 0.95R
  • Bin B has 3.95G + 9.05R
P(at least 1 Green) = 1 - P(2 Reds) = 1 - 9.05 / 13 * 8.05 / 12 = 46.7%

2nd method: Case by case

Three sets of possibilities for ball distribution in Bin B as found earlier:
  1. 5G + 8R with a probability of 16.5%
  2. 4G + 9R with a probability of 33.0% + 29.3% = 62.3%
  3. 3G + 10R with a probability of 6.6% + 14.6% = 21.2%
For each possibility, probabilities of drawing at least 1 Green are calculated by using the formula above.
  1. For 5G + 8R, it is 1 - 8 / 13 * 7 / 12 = 64.1%
  2. For 4G + 9R, it is 1 - 9 / 13 * 8 / 12 = 53.8%
  3. For 3G + 10R, it is 1 - 10 / 13 * 9 / 12 = 42.3%
Multiplying these probabilities of drawing at least 1 Green with their respective probabilities of ball distribution, we get 16.5% * 64.1% + 62.3% * 53.8% + 21.2% * 42.3% = 53.1%

Just like heehaww said, two methods yielded different results this time and the correct one is the one calculated by the case by case method.
Balls and bins Quote
10-18-2022 , 08:40 AM
Someone has alerted me to an even better solution! Consider the initial green ball in Bin A separately:

The chance of drawing it is P(transfer to Bin B)*P(draw it from B | present in B) = (1/3)(1/13) = 1/39

P(draw any green) = 1/39 + (38/39)(4/14) = 83/272

4/14 is the chance of drawing a green ball given that we don't draw that one.
Balls and bins Quote
10-25-2022 , 07:07 PM
I'm too lazy for the math, but it was an okay programming problem.

In Python:
Code:
import random
from collections import Counter

final_selections = []
for _ in range(10000000):
    bin_a = ['green']
    bin_b = ['green']*4 + ['blue']*10
    bin_b_select = [bin_b.pop(random.randrange(len(bin_b))) for _ in range(2)]
    bin_a += bin_b_select
    bin_a_select = [bin_a.pop(random.randrange(len(bin_a)))]
    bin_b += bin_a_select
    final_selection = random.sample(bin_b, 1)
    final_selections += final_selection

final_counts = Counter(final_selections)
prob_green = final_counts['green']/len(final_selections)

print(final_counts, '\n Probability of Green: ', round(prob_green, 3))

>>> Counter({'blue': 6959950, 'green': 3040050}) 
 Probability of Green:  0.304
(probably could be prettier but oh well)
Balls and bins Quote

      
m