Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1-a)
- vector <- c()
- tiradas <- c(10,100,1000,10000,100000,1000000)
- for (i in 1:length(tiradas)){
- vector <- c(vector, mean(sample(c(0,1), tiradas[i], replace = TRUE, prob = NULL)))
- }
- plot(1:length(tiradas), vector)
- 1-b)
- tiradas1 <- c()
- tiradas2 <- c()
- tiradas3 <- c()
- tiradas4 <- c()
- tiradas5 <- c()
- tiradas6 <- c()
- tiradas <- c(10,100,1000,10000,100000,1000000)
- for (i in 1:length(tiradas)){
- vector <- sample(6, tiradas[i], replace = TRUE, prob = NULL)
- tiradas1 <- c(tiradas1, sum(vector == 1)/length(vector))
- tiradas2 <- c(tiradas2, sum(vector == 2)/length(vector))
- tiradas3 <- c(tiradas3, sum(vector == 3)/length(vector))
- tiradas4 <- c(tiradas4, sum(vector == 4)/length(vector))
- tiradas5 <- c(tiradas5, sum(vector == 5)/length(vector))
- tiradas6 <- c(tiradas6, sum(vector == 6)/length(vector))
- }
- plot(tiradas, tiradas1)
- 1-c)
- 2)
- vector <- c()
- for (i in 1:10000){
- vector <- c(vector, sum(sample(6, 4, replace = TRUE, prob = NULL)))
- }
- tabla <- table(vector)
- plot(tabla)
- 3-a)
- vector <- sample(c('B','N'), 1, replace = TRUE, c(3/8, 5/8))
- 3-b)
- vector <- sample(c('B','N'), 8, replace = TRUE, c(3/8, 5/8))
- plot(table(vector))
- 3-c)
- vector <- c()
- for (i in 1:10000){
- vector <- c(vector, sum(sample(c('B','N'), 30, replace = TRUE, prob = c(3/8,5/8))=='N'))
- }
- tabla <- table(vector)
- plot(tabla)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement