Suppose a coin is tossed (with probability of head being $p$) 10 times,if the coin is tossed again 10 times independently,what is the probability that the two sequence will completely match?

I am getting no clue about this problem.I have tried but don't know how to start.

  • 2
    $\begingroup$ Solve it for 1 instead of 10 and think inductively. $\endgroup$
    – Neil G
    Jun 9 '16 at 3:54

This question has two reasonable interpretations. Neither requires any calculation at all, but only careful reasoning about independence and disjoint outcomes.

  1. Conditional on the first ten flips, what is the chance the next ten flips match them in sequence?

    If we were to re-order the sequences of both flips in the same way, the question would be the same and therefore would have to have the same answer. Consequently the answer does not depend on the specific sequence of results in the first ten flips, but only on how many heads appeared (say $x$ of them). We now only have to compute the chance for one specific such sequence, such as first flipping $x$ heads in a row and then flipping $10-x$ tails in a row. The independence assumption immediately gives the answer, which I leave to the reader.

  2. What is the unconditional chance? That is, what is the chance before any coin is flipped that the second sequence of ten results will be identical to the first sequence?

    The independence of the flips allows you to consider them in any order. Consider the first and eleventh flips together, which constitute two independent flips. The chance that they match is the chance that both are heads or both are tails, which (since these two events are disjoint) must be the sum of the two probabilities $$\Pr(\text{match})=\Pr(HH) + \Pr(TT)=p^2 + (1-p)^2.$$

    Similarly pair flip $i$ with flip $10+i$ for all $i=1,2,\ldots, 10$. The two sequences match if and only if all $10$ pairs are matches. Since the pairs are disjoint, their outcomes remain independent, producing an immediate answer, which again I leave to the reader.

An interesting way to check the answers is to note that the second answer must equal the first answer, summed over all possible outcomes of the first ten flips multiplied by their chances. Equating the two, generalizing from $10$ to $n$, and applying the Binomial distribution for the value of $x$ in the first $n$ flips gives the curious but easily proven identity

$$\sum_{x=0}^n\left[p^x(1-p)^{n-x}\right]\;\binom{n}{x}p^x(1-p)^{n-x} = \left(p^2 + (1-p)^2\right)^n.$$

A more pedestrian, but very effective, check is to compare the answers with a simulation. Here is R code to estimate the unconditional chance for specified $n$ (such as $10$) and chance of heads $p$. In each iteration, it counts the number of differences between the first $n$ and second $n$ sets of flips. The estimated probability is the proportion of simulations where those counts were zero.

The code outputs the estimate and its standard error. If the estimate lies within a couple standard errors of your calculated result, you're probably correct. When I ran it for $p=1/3$ and $n=10$ the output was

Estimate  Std.err 
 0.00288  0.00005 

It took one second to run a million iterations.

n <- 10
p <- 1/3
n.sim <- 1e6
x <- colSums(matrix((runif(n.sim*n) < p) != (runif(n.sim*n) < p), nrow=n))==0
(round(c(Estimate=mean(x), Std.err=sd(x)/sqrt(n.sim)), 5))
  • $\begingroup$ Alternatively, we can use the binomial distribution: x <- replicate(1e6,sum(rbinom(10,1,1/3)==rbinom(10,1,1/3)))==10, although it is a ridiculously slower method: 23.40 sec. versus 2.87 in my computer. $\endgroup$ Jun 11 '16 at 10:28

You need to consider whether the assumption that given a coin gave a "Head" in the earlier toss, is the occurrence of a "Tail" dependent on the previous event or not?

The sequence should only matter if the path taken to the last coin toss impacts the last coin toss. This would be true if we were sampling without replacement, but outcomes of coin tosses should be independent of each other.

Taking an example of 3 coin tosses, lets say the first instance was {H,T,H}, you can build a tree of possible outcomes:

                 First Toss
               /            \
          Head               Tail 
           |                   |
       2nd Toss             2nd Toss
       |      |             |     |
   Head       Tail       Head     Tail
     |         |          |         |
 3rd Toss   3rd Toss   3rd Toss   3rd Toss
  |    |     |    |     |    |     |    |
Head Tail *Head* Tail  Head Tail  Head Tail

The node marked with asterisk (*) denotes achieving the exact same sequence as the first time i.e. {H,T,H}.

Here, the total probability of the sequence which you have calculated as p.(1-p).p is the same irrespective of the sequence.

This can be simulated in R as follows:

ranvec <- runif(3 * 1000 * 1000)>0.5
ranDataFr <- as.data.frame( matrix( data=ranvec, nrow=1000000, ncol=3) )
names( ranDataFr) <- c("Toss1", "Toss2", "Toss3")
prob_of_HTH <- length( ranDataFr[
                     & ranDataFr$Toss2==FALSE
                     & ranDataFr$Toss3==TRUE , 1] )/1000000
[1] 0.125456

Which, after accommodating to float precision errors is approximately the same as the analytically derived value: 0.5 x (1 - 0.5) x 0.5 = 0.125

You can expand this for the 10-toss sequence in a similar manner.


Suppose each coin toss is independent and that the first sequence of (ten) flips is $X_1, X_2, \dots, X_{10}$, where $\forall i \in \{1,\dots,10\}: X_i \in \{H,T\} $ meaning each flip is either $H $ heads or $T $ tails. Let the observed value of the $i^{th}$ flip be denoted $F_i $ so that $\mathbb{P}(X_{i+10} = F_i) $ is the probability that the $i + 10$ flip is equal to the observed value of flip $i $.

What we want to solve for is then the probability of repeating the same sequence in the next ten flips (flips 11 to 20) $$\mathbb{P}(X_{11}=F_1,\dots,X_{20}=F_{10} \mid X_1=F_1,\dots,X_{10}=F_{10})$$ Since each flip is independent, (or as others like to say, the coin is "memoryless") it doesn't matter that we condition on the past. Rather, we just need to calculate $$\mathbb{P}(X_{11}=F_1,\dots,X_{20}=F_{10} )$$ Again, by independence, each flip in this sequence does not depend on the flips before or after ("memoryless"), reducing our calculation to the product $$\prod_{i=1}^{10} \mathbb{P}(X_{i+10} = F_i) = \prod_{i=1}^{10} p\cdot I(F_i = H) + (1-p) \cdot I(F_i = T)$$ where $I (\cdot) $ is the standard Boolean indicator function. You'll find that this expression evaluates to $p^n (1-p)^{10-n} $ where $n $ is the number of heads in the first ten flips.

  • $\begingroup$ Your equations make no sense at all. One way to see that is to note that they do not ever refer to the second set of flips! $\endgroup$
    – whuber
    Jun 9 '16 at 13:56
  • 2
    $\begingroup$ Much better, thank you! (+1) Because your final formula is a rather complicated expression for what ultimately is a simple answer, you might consider simplifying it (or, if you wish not to reveal the answer to a self-study question, at least point out that it is easily simplified). $\endgroup$
    – whuber
    Jun 9 '16 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.