Dear R-help, 

Could someone please try to explain this paradox to me? What is more likely to 
show up first in a string of coin tosses, "Heads then Tails", or "Heads then 
Heads"?  

##generate 2500 strings of random coin flips
ht <- replicate(2500,
                paste(sample(c("H", "T"), 100, replace = TRUE),
                      collapse = ""))

## find first occurrence of HT
mean(regexpr("HT", ht))+1    #mean of HT position, 4

## find first occurrence of HH
mean(regexpr("HH", ht))+1    #mean of HH position, 6

FYI, this is not homework, I have not been in school in years.  I saw a similar 
problem posed in a blog post on the Revolutions R blog, and although I believe 
the answer, I'm having a hard time figuring out why this should be? 

Thanks,
Erik Iverson

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to