beceb22

10-12

Jun 22nd, 2018
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #### PREGUNTA N°10
  2. ## a)
  3. rm(list = ls())
  4. Y2=vector()
  5. U=vector()
  6. n=100
  7.  
  8. for (i in 1:n) {
  9. U[i]=runif(1,0,1) #Variable de control
  10. Y2[i]=(exp((U[i]+U[i])^2))
  11. }
  12. c=-cov(Y2,U)/var(U)
  13. p=cor(U,Y2);p
  14. Var_IC=var(U)*(1-p^2)
  15. Var_IC
  16.  
  17. #### b)antiteticas
  18. rm(list = ls())
  19.  
  20. Y2=vector()
  21. U=vector()
  22.  
  23. n=100
  24.  
  25. for (i in 1:n) {
  26. U[i]=runif(1,0,1)
  27. Y2[i]=(exp((2*U[i])^2)+(exp((1-2*U[i])^2)))/2
  28.  
  29. }
  30.  
  31. var(Y2)/n
  32.  
  33. #### Pregunta 12
  34. ## a)
  35.  
  36. n <- 10000
  37. x <- runif(n, -1, 1)
  38. y <- runif(n, -1, 1)
  39. indice <- (x+y < 0)
  40. # Aproximación por simulación
  41. sum(indice)/n
Add Comment
Please, Sign In to add comment