Advertisement
beceb22

9

Jun 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. ## PREGUNTA 9
  2.  
  3. ## b) Simulación con variable de control
  4. ## Y=U (variable de control)
  5. rm(list = ls())
  6.  
  7. n <- 100
  8. X <- vector()
  9. U <- vector()
  10. med_Y=0.5
  11.  
  12. for(i in 1:n)
  13. {
  14. U[i]=runif(1,0,1) #variable de control
  15. X[i]=exp((U[i])^2)
  16. }
  17. c=-cov(X,U)/var(X)
  18. p=cor(U,X)
  19. Var_IC=var(U)*(1-p^2)
  20. Var_IC
  21.  
  22. ## c) Variable antiteticas
  23.  
  24. rm(list = ls())
  25. X=vector()
  26. U=vector()
  27. n=100
  28.  
  29. for (i in 1:n) {
  30. U[i]=runif(1,0,1)
  31. X[i]=(exp(U[i]^2)+(exp((1-U[i])^2)))/2
  32. }
  33. var(X)/n
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement