Re: [R] Head or Tails game

2012-08-05 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of darnold > Sent: Friday, August 03, 2012 9:18 PM > To: r-help@r-project.org > Subject: Re: [R] Head or Tails game > > Wow! Some great responses! >

Re: [R] Head or Tails game

2012-08-03 Thread arun
ylandt To: darnold Cc: "r-help@r-project.org" Sent: Friday, August 3, 2012 10:20 PM Subject: Re: [R] Head or Tails game On Aug 3, 2012, at 9:14 PM, darnold wrote: > David, > > set.seed(123)  # always good to make reproducible > winnings <- sum(sample(c(-1,1), 1, rep

Re: [R] Head or Tails game

2012-08-03 Thread arun
darnold To: r-help@r-project.org Cc: Sent: Friday, August 3, 2012 10:14 PM Subject: Re: [R] Head or Tails game David, set.seed(123)  # always good to make reproducible winnings <- sum(sample(c(-1,1), 1, replace=TRUE)) Unfortunately, that's not the game. The game requires 40 flips of

Re: [R] Head or Tails game

2012-08-03 Thread darnold
Wow! Some great responses! I am getting some great responses. I've only read David, Michael, and Dennis thus far, leading me to develop this result before reading further. lead <- function(x) { n <- length(x) count <- 0 if (x[1] >= 0) count <- count + 1 for (i in 2:n) { if (x[i] > 0 |

Re: [R] Head or Tails game

2012-08-03 Thread Jeff Newmiller
Two possible solutions below. On Fri, 3 Aug 2012, darnold wrote: Hi, Reading about a "Heads and Tails" game in http://www.dartmouth.edu/~chance/teaching_aids/books_articles/probability_book/amsbook.mac.pdf Introduction to Probability (Example 1.4, pp. 5-8). You toss a coin 40 times. If heads,

Re: [R] Head or Tails game

2012-08-03 Thread William Dunlap
to:r-help-boun...@r-project.org] On > Behalf > Of darnold > Sent: Friday, August 03, 2012 7:14 PM > To: r-help@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)

Re: [R] Head or Tails game

2012-08-03 Thread Michael Weylandt
On Aug 3, 2012, at 9:14 PM, darnold wrote: > David, > > set.seed(123) # always good to make reproducible > winnings <- sum(sample(c(-1,1), 1, 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. >

Re: [R] Head or Tails game

2012-08-03 Thread darnold
David, set.seed(123) # always good to make reproducible winnings <- sum(sample(c(-1,1), 1, 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.nabb

Re: [R] Head or Tails game

2012-08-03 Thread David Winsemius
On Aug 3, 2012, at 5:55 PM, darnold wrote: Hi, Reading about a "Heads and Tails" game in http://www.dartmouth.edu/~chance/teaching_aids/books_articles/probability_book/amsbook.mac.pdf Introduction to Probability (Example 1.4, pp. 5-8). You toss a coin 40 times. If heads, Peter wins $1, tails

[R] Head or Tails game

2012-08-03 Thread darnold
Hi, Reading about a "Heads and Tails" game in http://www.dartmouth.edu/~chance/teaching_aids/books_articles/probability_book/amsbook.mac.pdf Introduction to Probability (Example 1.4, pp. 5-8). You toss a coin 40 times. If heads, Peter wins $1, tails, he loses $1. I think I can do that ok with: