The R function rnorm gives samples according to Normal Distribution
# ex2.R sig <- rnorm(10000) num_pos <- sig>=0 a <- sum(num_pos)/length(num_pos)*100 print(sprintf('The percentage of positive numbers in sig is %.2f.', a)) print(sprintf('sig has %.5f mean.',mean(sig))) print(sprintf('sig has %.5f std away from 1',abs(sd(sig)-1))) hist(sig,breaks = 45, xlab ='x', ylab ='Frequency', main = 'Normal Distribution',col = 'gray') ## [1] "The percentage of positive numbers in sig is 50.26." ## [1] "sig has 0.00961 mean." ## [1] "sig has 0.00734 std away from 1"