Tossing biased coins in majority voting batches

probabilitystatistics

Supposed having $n$ for the number of multiple biased coins, each one having the probability of $p$ for showing heads. By tossing all coins at once, what would be the probability of having more heads than tails? (You could assume that $n$ is an odd number) To solve this part of the problem, I found a similar question which is about the probability of having more heads than tails in tossing one single biased coin for $n$ times. The best answer suggested
$$\sum_{k=0}^{\left\lfloor\frac n2\right\rfloor}{n\choose k}p^{n-k}(1-p)^k$$
But I'm not quite sure if tossing one coin for $n$ times is identical as tossing $n$ coins for one time.

Nevertheless, the problem does not end here. Now, let us assume that we have $m$ batches (again, could be an odd number), each one containing $n$ biased coins. If the majority of coins in a single batch is facing head, the output of the batch will be $1$. Otherwise, it will be either $1$ with the probability of $q$, or $0$ with the probability of $1-q$. The batches themselves form a bigger mega-batch with same laws applied ($1$ as the final output if the majority of the batches are $1$, either $1$ or $0$ with the probabilities $q$ and $q-1$ if the majority of the batches are $0$). In such case, what would be the probability of having a $1$ as the final output of the mega-batch?


P.S.: I've simulated the problem in the following Python code

    import random
    import statistics
    
    def weighted_random(p):
        return 1 if random.random() < p else 0
    
    def C():
        """
        Coin flipping function
        """
        return weighted_random(0.7) # p
    
    
    def B(*args):
        """
        Batch voting function
        """
        majority = statistics.mode([*args])
        if majority == 0:
            return weighted_random(0.1) # q
        return 1
    
    
    def test_megabatch(epochs=1_000):
        sum = 0
    
        for _ in range(epochs):
            c1 = C()
            c2 = C()
            c3 = C()
            c4 = C()
            c5 = C()
            c6 = C()
            c7 = C()
            c8 = C()
            c9 = C()
    
            b1 = B(c1, c2, c3)
            b2 = B(c4, c5, c6)
            b3 = B(c7, c8, c9)
    
            b = B(b1, b2, b3)
    
            sum +=b
       
        return sum
    
    
    print(test_megabatch(10_000) / 10_000) # approximately 0.91

where $n=3$, $m=3$, $p=0.7$ and $q=0.1$ . But I need to actually solve the problem rather than brute-forcing it!

Best Answer

For the first part, it's true that tossing all $n$ coins at once is the same as tossing a single coin $n$ times. (Imagine that your super-powers include the ability to observe the order in which the coins land.) Seriously, if we toss the coins one at a time, and let $X_i$ be an indicator random variable that is $1$ if the $i$th toss is heads and $0$ if it is tails, then we want $$\Pr\left(\sum X_i>\frac n2\right)$$. If we toss all the coins at once, imagine that the coins have been numbered from $1$ to $n$ and define $X_i$ as $1$ if coin number $i$ comes up as head and $0$ if it comes up tails. Then we want the same probability, and in either case, the $X_i$ are independent Bernoulli r,v,'s with rpobability of success $p$.

Once you have determined that the probability of having more heads than tails in a single batch is $q$, then you can consider a mega batch as tossing $m$ biased coins, each with probability of $q$ of coming up heads. Use exactly the same formula as before, with $q$ in place of $p$ and $m$ in place of $n$.

Related Question