# I Statistical problem of drawing colored balls from boxes

1. Apr 12, 2017

### KFC

Last week I went to a state fair which I saw a game of lucky draw. There is two sealed boxes, contains bunch of 4 different color balls: red, blue, green and white. Here is the game rule. Players make an initial draw on box one, if players get a white ball, lose the game; if getting a red one, get 4 free draws; getting a blue one, get 3 free draws; getting a green one, get 2 free draws. Players make the free draws in the second box. In this scenario, in any draw if players getting any red ball, 3 more draws added; any blue one, 2 more draws added; getting any green one, 1 more draw added; getting white one does not award additional drawing chance but will NOT lose the game immediately. The game is over when all drawing chances used up. The reward gift based on how many total color balls are obtained. I am interesting in finding out how many draws in average will this game given in case a non-white ball was drawn in first round?

I did some math based on what I learnt from the text as follows. Let's assume for the first draw, the chance to get a red/blue/green ball is $p_1=0.05, p_2=0.1$ and $p_3=0.17$ respectively so 1-0.05-0.1-0.17=0.68 chance will get a white one and lose the game.

After the first draw, if not losing the game, the chance to get a red/blue/green ball is $q_1=0.01, q_2=0.03$ and $q_3=0.045$ respectively. So in this scenario, the contribution to the average time from the initial win 4/3/2 is

$\displaystyle E_4 = \frac{4}{1-(q_1\times3 + q_2\times 2 + q_1\times 1)};$

$\displaystyle E_3 = \frac{3}{1-(q_1\times3 + q_2\times2 + q_1\times 1)};$

$\displaystyle E_2 = \frac{2}{1-(q_1\times 3 + q_2\times 2 + q_1\times 1)}.$

But note that there is $p_1/p_2/p_3$ chance to get 4/3/2 draws initially. So the total average number of draws should be

$\overline{D} = p_1 E_4 + p_2 E_3 + p_3 E_2$

By plugging the numbers into that, I got 3.035 draws. I am not quite sure this is correct because I write a short program to simulate this game but I get the average draw to be 1.05 instead.

2. Apr 12, 2017

### Staff: Mentor

With your formulas I get 0.97 draws from the second box. If we add the one draw from the first box, it increases to 1.97.

How did you get 3.035? The denominator is 0.865, you have a 1/3 chance to get draws at all, and get about 3 - without calculator you can see that the value has to be around 1.

3. Apr 14, 2017

### KFC

Sorry, I didn't complete the math. I typed all but after I preview that some part were gone, don't know why. Anyway, let me rephrase it here. One thing is very important I missed in the question, in second box game, place the drawn ball back to the box, so the probability of drawing red/blue/green ball is always q1, q2 and q3 separately.

In box 2, the expect # of draws for 3/2/1 is $3q_1/(q_1+q_2+q_3)$, $2q_2/(q_1+q_2+q_3)$ and $q_3/(q_1+q_2+q_3)$. So

$D = \displaystyle{\frac{3q_1 + 2q_2 + q_3}{q_1+q_2+q_3}} = 1.588$
Note that it is not 1/3 to get draws because there will be white balls in the box which gain no draw if get one.

Now consider the chance to start the second game, the expectation when 4/3/2 initial obtained is

$E_4 = \displaystyle{\frac{4}{1-(3q_1 + 2q_2 + q_1)}}, E_3 = \displaystyle{\frac{3}{1-(3q_1 + 2q_2 + q_1)}}, E_2 = \displaystyle{\frac{2}{1-(3q_1 + 2q_2 + q_1)}},$

Now consider the probability to get the red/blue/green ball in the first box

$\overline{\mbox{# draw}} = (p_1E_4 + p_2E_3 + p_1E_2)/(p_1+p_2+p_3) = 3.0347$

Here we need to normalize it with the total probability to get red/blue/green ball. That is how I get the 3.0347.

4. Apr 14, 2017

### Staff: Mentor

I don't understand your new calculation of D at all. What does it calculate, why, how? Where do you use this result?
Only if you want the expected number of draws under the condition that it is not zero. Are you really interested in this case?

5. Apr 15, 2017

### KFC

$E_n$ is obtained from $D$ in the way

$E_n = \frac{n}{1- D\sum q_i}$

Well, I just find that there is a bug in my program, I corrected it and my simulation shows the same result (3.034) now. So I think the above calculation should be correct.

Here is what I did in my code
Setup a game with two box, in box 1, there will be $p_1, p_2, p_3$ chance to get red/blue/green ball and $1-(p_1+p_2+p+_3)$ chance to get a white one; in box 2, there will be $q_1, q_2, q_3$ chance to get red/blue/green balls and $1-(q_1+q_2+q_3)$ chance to get white one. Several variables setup: count_of_win_games used to count the time winning a game (got 4/3/2 in box 1), total_count_draws counts total_number_draws in the simulation. I simulate 1,000,000,000 games, in each game

total_count_draws=0; total_number_draws=0
1) draw a ball from box 1 at the given weight
2) if got a white one, game over, start a different game and goto 1)
3) if got a red/blue/green ball, given 4/3/2 initial draws; increase total_count_draws by one; total_number_draws=total_number_draws+4/3/2
4) repeat drawing ball in box 2; each time, draw a ball at the given probability distribution;
4a) if get a while ball, do nothing
4b) if get a red/blue/green, total_number_draws =total_number_draws + 3/2/1; give 3/2/1 more draw
5) until no more draws left

The average number of draws is then calculated as total_number_draws/total_count_draws. I got 3.035

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted