[R] Offtopic, HT vs. HH in coin flips
David Winsemius
dwinsemius at comcast.net
Mon Aug 31 22:11:29 CEST 2009
Case starting with H: Pr= 0.5
H first H second
Subcase 1a: Pr= 0.5 * 0.5 = 0.25
----
H first T second... leads to TH evenually
Subcase 1b: Pr = 0.5 * 0.5 = 0.25
===================
Case T first: Pr = 0.5
all subcases lead to TH first
--
David.
On Aug 31, 2009, at 3:16 PM, Erik Iverson wrote:
> 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 at 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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list