The Number of Times a Coin Needs to Be Flipped Until Head Appears

2.3k Views Asked by At

I need to find out the number of times a fair coin is needed to flipped, until head appears for the first time.

Now, the options are: 2, 8, 16, and 64.

I don't think it can be calculated. Because every time a coin is flipped, the chance of head appearing is .5 or 50%.

How to calculate this?

Edit: I wrote the question according to the original question I found. The title was written accordingly. Seeing an experienced user's edit on my question, I guess the correct title is: 'The Average Number of Times a Coin Needs to Be Flipped Until Head Appears'.

3

There are 3 best solutions below

5
On BEST ANSWER

You are absolutely correct in saying that the expectation of every single coin flip (read Bernoulli trial) is 1/2. So if the question is what is the probability that it takes 1 single coin flip to get a head, then the answer is 1/2.

What if the question was, "What is the probability that it takes 2 coin flips to get a head?" In this case it would be 1/2 times 1/2, or 1/4.

But the actual question you are asked is slightly more subtle: if you were to repeat the experiment, which is defined as counting the number of coin flips until you get a head, what would be the expected number of tosses (average)? This is a different random variable than the one you are making reference to in your question, i.e. tossing a coin and checking whether it is heads or tails.

The actual computation is straightforward if you know that this is a geometric distribution, and you are looking for the expectation (the mean).

If you want to go more into the derivation, check this video.


Simulation in R:

tosses_til_head <- 0 # An empty vector

for(sim in 1:100000){ # Number of simulations 100,000.
        i <- 1 # Counter
    repeat{
            if(rbinom(1,1,.5) == 0){ # Coin toss (fair) with Boolean (if tails...)
              i <- i + 1} # ... increase the counter by 1.
      else{
            break} # If heads, stop!
    }

tosses_til_head[sim] <- i # Collect the number of tosses before we got H.
}

mean(tosses_til_head) # Average of these 100,000 simulations.

# 2.00416 # Result of one run (not seeded).
3
On

If we define the random variable $X$ as the number of flips we take until we get our first head, then what we are looking for is the average value of $X$ if we did this over and over again.

You are correct that for each flip, the probability of a head is $0.5$ and similarly the probability of a tails is $0.5$

If we succeed in one flip, then we got a heads on the first flip. If we don't, that means we got a tails, and then we need to essentially "start over" and try again to flip for a heads.

So using expected value, we see that

$$E(X) = 1(.5) + \Bigl(1+E(X)\Bigr)(0.5)$$

Simplifying the above results in $E(X) = 2$

On average the first heads will appear after $2$ flips

0
On

geometric distribution $E=\cfrac{1}{p}$. Or by definition of expectation:

$0.5\times 1+0.25\times 2+0.125\times 3+\cdots+0.5^k\times k+\cdots=2$