[R] Head or Tails game

Michael Weylandt michael.weylandt at gmail.com
Sat Aug 4 04:20:36 CEST 2012



On Aug 3, 2012, at 9:14 PM, darnold <dwarnold45 at suddenlink.net> wrote:

> 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.
> 

colSums(matrix(sample(c(-1, 1), 40*10000, TRUE), ncol = 10000))

or some such

Michael

> 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.



More information about the R-help mailing list