T <- function(x) 0.4*x[1] + 0.2*x[2] + 0.1*x[3] + 0.1*x[4] nrep <- 100000 dimc <- 4 x <- rnorm(dimc*nrep,mean=100,sd=10) x <- matrix(x,nrow=nrep) t <- apply(x,1,T) mean(t) var(t) mean((t-100)^2)