N <- 1000000 X <- rnorm(N, 0, 1) mean(X*sin(X)) N <- 1000000 X <- rnorm(N, 0, 1) Y <- ifelse(X*sin(X)>0.5, 1, 0) mean(Y) N <- 1000000 X <- runif(N, 0, pi) pi*mean(sin(X))