rafalab / dsbook-part-2

Repository for Advanced Data Science Book
54 stars 25 forks source link

Chapter 9, exercise 4 #6

Open jcornickm opened 3 weeks ago

jcornickm commented 3 weeks ago

We are asked to generate a sample of size N from an urn with 52% blue beads. The code provided is as follows:

N <- 1000 
p <- 0.52
x <- rbinom(N, 1, 0.5)

This is drawing a sample from a population with 50% blue beads. The correct code would be either

x <- rbinom(N,1,p)  

or

x <-rbinom(N,1,0.52)

Am I mistaken?