# Generate 10 Standard normal random numbers
random_nums <-rnorm(10)
print("Standard normal random numbers:")
print(round(random_nums, 4))
# Generate random numbers with a mean of 70 and a standard deviation of 10 (simulated exam scores)
set.seed(123)
scores <-rnorm(1000, mean=70, sd=10)
print(paste("Calculate the mean of 1000 scores:", round(mean(scores), 2)))
print(paste("Standard Deviation:", round(sd(scores), 2)))
# View distribution
print(summary(scores))
Executing the above code produces the following output:
"Standard normal random numbers:" -0.5605 -0.2302 1.5587 0.0705 0.1293 1.7151 0.4609 -1.2651 -0.6869 -0.4457 "Calculate the mean of 1000 scores: 69.97" "Standard Deviation: 10.03" Min. 1st Qu. Median Mean 3rd Qu. Max. 32.69 63.36 69.82 69.97 76.55 106.42
R Language Examples