> -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!
>
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
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
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 |
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,
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)
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.
>
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
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
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:
10 matches
Mail list logo