[R] Offtopic, HT vs. HH in coin flips
Greg Snow
Greg.Snow at imail.org
Mon Aug 31 21:55:55 CEST 2009
Well,
If the first flip is H, then the HT pattern occurs with the first flip in the second run (after however long the 1st run of heads is). If the first flip is T, then the second run will be H's and the HT pattern will be the first flip of the 3rd run. So the HT pattern will occur after 1 or 2 runs (at the beginning of the 2nd or 3rd).
On the other hand, the HH pattern can occur after any number of runs (given that the H runs are only 1 long).
This means that the HH pattern has a higher probability of being in the right tail of the distribution which will increase the mean. The probability of HH or HT as the 1st pair is the same.
Just looking at the first 3 flips, the probability of HH occurring first at flips 2 and 3 has only 1 chance (THH, HHH means that the first HH was at 1 and 2) and therefore has probability 1/8.
The probability of HT first occurring at 2 & 3 has 2 options THT or HHT and therefore is twice as likely.
Does this help?
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Erik Iverson
> Sent: Monday, August 31, 2009 1:17 PM
> To: r-help at r-project.org
> Subject: [R] Offtopic, HT vs. HH in coin flips
>
> 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.
More information about the R-help
mailing list