vendredi 7 février 2020

Generate 1000 random samples of 4 digits with replacement from the population of digits

Plot the distribution of the sample proportion of 1’s using a Histogram.

I've tried this, but don't believe that it is right:

set.seed(123)

y<-replicate(1000,sample(pop, size=4, replace = TRUE), simplify = FALSE)

d<-length(y) 

Taking the observation 1 from vector x and storing it in variable b

e<-x[x==1]

The number of ones stored in vector x stored in vector c

f<-length(e)

Finding the proportion of 1s in vector x

prop<-f/d

prop

Additionally, I've tried to make a histogram out of this code, but it won't return anything for some reason. any ideas?




Aucun commentaire:

Enregistrer un commentaire