y<-rbinom(10000000,3,0.50) # simulate 10000000 times the no.ofsuccesses in 3 trials
head(y,10) # the first 10 of the 10 million observations generated [1] 3 2 2 0 2 3 1 0 1 2
mean(y);sd(y)[1] 1.500123
[1] 0.8658677
see equation (2.1)
y<-rbinom(10000000,3,0.50) # simulate 10000000 times the no.ofsuccesses in 3 trials
head(y,10) # the first 10 of the 10 million observations generated [1] 3 2 2 0 2 3 1 0 1 2
mean(y);sd(y)[1] 1.500123
[1] 0.8658677
y<-runif(10000000, min=0, max=100) # runif simulates uniform random variable
head(y,5) # first 5 of ten million generated (to 6 decimal places)[1] 80.90635 36.73495 12.70536 17.41020 71.02995
mean(y);sd(y) # mean and standard deviation of ten million simulated uniform rv's[1] 49.99301
[1] 28.86167
Compute the expectation and variance of \(Z\).