Message-ID: <E66794E69CFDE04D9A70842786030B932E134C@PA-MBX01.na.tibco.com>
Date: 2012-08-04T03:55:28Z
From: William Dunlap
Subject: Head or Tails game
In-Reply-To: <1344046448137-4639145.post@n4.nabble.com>
Use a loop to run over the 10,000 reps and in each rep use
rle(x>=0) to look at the runs of nonnegative numbers, postprocessing
its output a bit to count them.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of darnold
> Sent: Friday, August 03, 2012 7:14 PM
> To: r-help at r-project.org
> Subject: Re: [R] Head or Tails game
>
> David,
>
> set.seed(123) # always good to make reproducible
> winnings <- sum(sample(c(-1,1), 10000, replace=TRUE))
>
> Unfortunately, that's not the game. The game requires 40 flips of a coin.
>
> Then you have to play the game 10,000 times.
>
> D.
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Head-or-Tails-game-
> tp4639142p4639145.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.