Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## PREGUNTA 9
- ## b) Simulación con variable de control
- ## Y=U (variable de control)
- rm(list = ls())
- n <- 100
- X <- vector()
- U <- vector()
- med_Y=0.5
- for(i in 1:n)
- {
- U[i]=runif(1,0,1) #variable de control
- X[i]=exp((U[i])^2)
- }
- c=-cov(X,U)/var(X)
- p=cor(U,X)
- Var_IC=var(U)*(1-p^2)
- Var_IC
- ## c) Variable antiteticas
- rm(list = ls())
- X=vector()
- U=vector()
- n=100
- for (i in 1:n) {
- U[i]=runif(1,0,1)
- X[i]=(exp(U[i]^2)+(exp((1-U[i])^2)))/2
- }
- var(X)/n
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement