3
$\begingroup$

A coin is tossed n times and is generating a sequence of heads and tails. A subsequence of consecutive heads is called a run of heads. For example in sequence HCHHHCCHHC there are two runs of lenght 3 and 2 and the longest run of heads is 3. For a sequence of length n = 1000 the longest run is equal to 6. Having this information do you believe the coin is fair or not?

Do you have ideas how to construct appriopriate test for such problem? Any help would be much appreciated. Thank you.

$\endgroup$
  • $\begingroup$ Thank you for your answer. My understanding is that this test is focused on number of runs in a sequence not maximal length of run in a given sequence. Could you please advise how would you use it in this situation? $\endgroup$ – pocraka Jun 30 '17 at 9:40
  • $\begingroup$ @Bey The Wald–Wolfowitz runs test does not have a fair coin as the null hypothesis. The natural test would be just to compare the numbers of Heads and Tails, unless you wanted to include independent identical distributions in the null hypothesis as well. $\endgroup$ – Henry Jun 30 '17 at 10:42
2
$\begingroup$

The natural test for a fair coin would be to compare the numbers of Heads and Tails, unless you wanted to include independent identical distributions in the null hypothesis as well (which you might if you did not conduct the test)

But you have said you want to look at the longest run

$6$ is rather short for the longest run in $1000$ tosses of a fair coin which is i.i.d. equally probably heads or tails. Since an i.i.d. unfair coin would tend to give longer runs, the doubt here could be that $6$ might come from a non-i.i.d process, possibly an attempt to fake a random sequence

You might intuitively guess that the longest run could be of the order of $\log_2(n)$ so about $10$ in this case ($10$ is indeed the median and mode here, and slightly below the expectation).

There are explicit expressions but it may be quicker to use a Markov calculation, producing something like the following, which suggests that at over $95\%$ confidence you might reject the null hypothesis when seeing longest runs of $7$ or fewer or of $16$ or more from a sequence of $1000$ results

run     prob
 6      0.0003
 7      0.0180
 8      0.1208
 9      0.2370
10      0.2387
11      0.1699
12      0.1014
13      0.0553
14      0.0289
15      0.0147
16      0.0074
17      0.0037
18      0.0019
19      0.0009
20      0.0005
21      0.0002
22      0.0001
$\endgroup$
0
$\begingroup$

Your question can be interpreted in several different ways (as the previous answerers already did). Here is my interpretation:

Suppose a coin was tossed $n$ times and generated a sequence of heads and tails. We do not see that sequence however and know only the length of the longest head run. Is there a way to estimate the probability of getting heads in one toss?

Yes, it is. Even with only this information available we can build the a consistent estimator for the probability of getting heads in one toss. Suppose $L_n$ is the length of the longest head run after $n$ tosses. Then our estimator will be $$n^{-\frac{1}{L_n}}$$ It's consistency follows from the facts, that, according to "The Longest Run of Heads" by Marc F. Shilling, if $p$ is the probability of getting heads, then

$$E[L_n] = \frac{ln(n)}{ln(p^{-1})} + O(1)$$

and

$$Var[L_n] = O(1)$$

$\endgroup$

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.