Advertisement
tomasfdel

Proba Práctica 3

Apr 5th, 2018
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.33 KB | None | 0 0
  1. 1-a)
  2. vector <- c()
  3. tiradas <- c(10,100,1000,10000,100000,1000000)
  4. for (i in 1:length(tiradas)){
  5.   vector <- c(vector, mean(sample(c(0,1), tiradas[i], replace = TRUE, prob = NULL)))
  6. }
  7. plot(1:length(tiradas), vector)
  8.  
  9.  
  10. 1-b)
  11. tiradas1 <- c()
  12. tiradas2 <- c()
  13. tiradas3 <- c()
  14. tiradas4 <- c()
  15. tiradas5 <- c()
  16. tiradas6 <- c()
  17. tiradas <- c(10,100,1000,10000,100000,1000000)
  18. for (i in 1:length(tiradas)){
  19.   vector <- sample(6, tiradas[i], replace = TRUE, prob = NULL)
  20.   tiradas1 <- c(tiradas1, sum(vector == 1)/length(vector))
  21.   tiradas2 <- c(tiradas2, sum(vector == 2)/length(vector))
  22.   tiradas3 <- c(tiradas3, sum(vector == 3)/length(vector))
  23.   tiradas4 <- c(tiradas4, sum(vector == 4)/length(vector))
  24.   tiradas5 <- c(tiradas5, sum(vector == 5)/length(vector))
  25.   tiradas6 <- c(tiradas6, sum(vector == 6)/length(vector))
  26. }
  27. plot(tiradas, tiradas1)
  28.  
  29.  
  30. 1-c)
  31.  
  32.  
  33. 2)
  34. vector <- c()
  35. for (i in 1:10000){
  36.   vector <- c(vector, sum(sample(6, 4, replace = TRUE, prob = NULL)))
  37. }
  38. tabla <- table(vector)
  39. plot(tabla)
  40.  
  41.  
  42. 3-a)
  43. vector <- sample(c('B','N'), 1, replace = TRUE, c(3/8, 5/8))
  44.  
  45. 3-b)
  46. vector <- sample(c('B','N'), 8, replace = TRUE, c(3/8, 5/8))
  47. plot(table(vector))
  48.  
  49. 3-c)
  50. vector <- c()
  51. for (i in 1:10000){
  52.   vector <- c(vector, sum(sample(c('B','N'), 30, replace = TRUE, prob = c(3/8,5/8))=='N'))
  53. }
  54. tabla <- table(vector)
  55. plot(tabla)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement