Finding the average time with given probability

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
KFC
Messages
477
Reaction score
4
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.
 
on Phys.org
KFC said:
But how to find the maximum possible number of draws?
There is no maximum possible. You could possibly draw a red ball each time.
 
Last edited:
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.
 
KFC said:
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.

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:

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
    return total_counter / n_trials

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/