4
$\begingroup$

Recently, I've seen several news articles (e.g., New York Times) referring to the article Surprised by the Gamber's and Hot Hand Fallacies? A Truth in the Law of Small Numbers by Miller and Sanjurjo. In it the authors write

Jack takes a coin from his pocket and decides that he will flip it 4 times in a row, writing down the outcome of each flip on a scrap of paper. After he is done flipping, he will look at the flips that immediately followed an outcome of heads, and compute the relative frequency of heads on those flips. Because the coin is fair, Jack of course expects this empirical probability of heads to be equal to the true probability of flipping a heads: 0.5. Shockingly, Jack is wrong. If he were to sample one million fair coins and flip each coin 4 times, observing the conditional relative frequency for each coin, on average the relative frequency would be approximately 0.4.

I do not understand how they arrive at 0.4. Per the experiment below, 0.5 appears correct. I've also posted the code on github. I suspect my confusion is more about intrepreting what "Jack" is measuring than my code. My code represents my understanding of what they are trying to simulate Any help clearing this up would be appreciated.

    ncoins<-1000000
    nflips<-4
    flips<-matrix(rbinom(ncoins*nflips,1,0.5),nrow=ncoins,ncol=nflips)
    results<-matrix(NA,nrow=nflips,ncol=3)
    row.names(results)=paste("Flip ",seq(1,nflips))
    row.names(results)[nflips]="Total"
    colnames(results)<-c("NSuccess","NConsecSuccess","Percent")

    eval_flips<-function(flips,i){
        out<-list()
        idx<-flips[,i]==1
        out$nsuccess<-sum(idx)
            out$nconsecsuccess<-sum(flips[idx,i+1])
        return(out)
    }

    for (i in 1:(nflips-1)){
        flip.result<-eval_flips(flips,i)
        results[i,"NSuccess"]<-flip.result$nsuccess
            results[i,"NConsecSuccess"]<-flip.result$nconsecsuccess
    }
    results<-data.frame(results)
    results[nflips,1]<-sum(results[1:(nflips-1),1])
    results[nflips,2]<-sum(results[1:(nflips-1),2])
    results$Percent<-results$NConsecSuccess/results$NSuccess
    results

            NSuccess NConsecSuccess   Percent
    Flip  1   499862         249956 0.5000500
    Flip  2   499900         249809 0.4997179
    Flip  3   500288         250374 0.5004597
    Total    1500050         750139 0.5000760
$\endgroup$
  • $\begingroup$ I'm not very familiar with R, so it's not very easy for me to read the code; but what you are supposed to do is to compute the conditional probability for each run of 4 coin flips separately, and then average these probabilities over all runs (excluding those without any coin flips following heads). Is that what you are doing? I am getting 0.4 with Matlab, so I am pretty sure the authors' claim is accurate. $\endgroup$ – amoeba Nov 1 '15 at 23:12
  • 3
    $\begingroup$ Also, you don't really need to simulate. There are only 16 possible outcomes of 4 coin flips. One of them TTTT does not have heads, one TTTH has heads only in the end. Exclude those. We are left with HHHH (cond probability of H following H is 1), HHHT (2/3), HHTH (2/3), HHTT (1/2), HTHH (1/2), HTHT (0), HTTT (0), HTTH (0), THHH (1), THTH (0), THHT (1/2), THTT (0), TTHH (1), TTHT (0). Now average the numbers: Answer: 5/12. $\endgroup$ – amoeba Nov 1 '15 at 23:23
  • 2
    $\begingroup$ @amoeba I get $17/42 \approx 0.40$. The calculation in R is sim <- apply(expand.grid(0:1,0:1,0:1,0:1), 1, function(x) c(sum(x[-1] & x[-n]), sum(x[-n]))); mean(sim[1, ]/sim[2, ], na.rm=TRUE) $\endgroup$ – whuber Nov 1 '15 at 23:31
  • 2
    $\begingroup$ @whuber's answer is correct: HHTH should have expected value 1/2, not 2/3 $\endgroup$ – Cliff AB Nov 1 '15 at 23:36
3
$\begingroup$

My understanding of what you are doing differently is that in the paper, they are taking an average of averages (i.e. for each set of 4)...regardless of how many samples (i.e. how many leading H's).

To demonstrate the difference: suppose you saw these two sequences:

HHHH

HTTT

The way you are counting it (I believe, only skimmed your code), it would be 4 H's that have a following flip, 3 for which have a following H, so $\hat p = 0.75$.

But from my understanding, they would calculate this as the first trial had 3 H's with a following flip, all of which are followed by an H, so $\hat p_1 = 1$ and in the next trial there is one H, followed by a T, so $\hat p_2 = 0$, making $\hat p_. = 0.5$, where $\hat p_.$ is the (unweighted) average of averages.

I'm guessing that if they took a weighted average of the $\hat p_i$'s, the answer would probably be the same. But that's gut feeling, not actually having sat down to work it out.

| cite | improve this answer | |
$\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.