# I Finding the average time with given probability

1. Apr 21, 2017

### KFC

Hi all,
I am thinking a problem of drawing a ball in a sealed box. Assuming there is a box, contains plenty red and white balls, the number of red and white balls are unknown but let's assume there will be $p$ chance to draw a red ball and $q=1-p$ chance to get a white one. Those probability is constant throughout the calculation. Let assume that at beginning we start the game by picking one ball out of the box, if it is a red one, there will be 3 more draws given; otherwise, game over.

For each draw out of 3, if you get a red ball, 3 more draws added other wise, use up one chance until all draws used up. I wonder if there is any way to estimate the maximum draws could be at the given $p$ and $q$?

I can estimate the average draws to be about 3.01993 if #p=0.006659#. But how to find the maximum possible number of draws? I write a program to simulate this process for billions times and I see that in some game I could get up to 21 draws. Is it any way to compute this number in theory? Thanks.

2. Apr 21, 2017

### Staff: Mentor

There is no maximum possible. You could possibly draw a red ball each time.

Last edited: Apr 21, 2017
3. Apr 21, 2017

### BvU

In your scenario there is no maximum on the number of draws.
You make things complicated. Easier: flip a coin many times. There is a nonzero probability for all heads, no matter how many times you flip.

4. Apr 21, 2017

### StoneTemplePython

I think you are probably asking for a lot more than you think / want here.

For starters, either your specification of the problem, or your code seems to be buggy. It would also be prudent to explicitly state that you are sampling with replacement from the box, or instead, tossing a coin.

My understanding is that this can be interpreted as starting with a score of $0$. If we get a white ball, our score has $-1$ added to it. If we get a red ball, the score is incremented by $+2$. We stop whenever our score is $=-1$.

If my understanding is correct, this maps to a simulation (and analytical result) that is markedly different than what you have stated for $p=0.006659$ -- i.e. it gets you $\approx 1.0203842$ draws on average until the game ends. This is the associated code:

Code (Python):

import numpy as np
import numba
# in Python 3.x

@numba.jit(nopython= True)
def do_sim(p_red, n_trials):
total_counter = 0
for trial in range(n_trials):
local_counter = 0
score = 0
while score > -1:
my_random_num = np.random.random()
if my_random_num <= p_red:
score += 2
else:
score -= 1
local_counter += 1
total_counter += local_counter

do_sim(p_red = 0.006659, n_trials = 10000000)

It's worth pointing out that if you play this game and $p \leq \frac{1}{3}$, the game will end with probability one. If $p \gt \frac{1}{3}$ your stopping time is actually a defective random variable -- i.e. $\infty$ has positive probability.

In the case of $p = \frac{1}{3}$ the game ends with probability one, but the expected draws until ending $= \infty$. For $p \lt \frac{1}{3}$, you can use Wald's equality and recover that the expected draws until ending is $\frac{1}{1-3p}$.

As mentioned by others, you can't put a hard bound on any finite natural number of draws. However, for $p \lt \frac{1}{3}$, you can use tools like Markov's inequality to get a (loose) probabilistic bound on the number of draws.

Your problem actually seems to be a variant of a recent Riddler Classic puzzle going under the name of micro-organism multiplication. The solution is found here under the title "Solution to last week's riddler classic"

https://fivethirtyeight.com/features/can-you-rule-riddler-nation/