Why Output of mean of normal random variable created using rnorm equals to 10 is not 10 in manual calculation with R?

R ProgrammingServer Side ProgrammingProgramming

When we find the mean of normal random variable which is created with rnorm(“sample_size”,10) is not 10 because rnorm will create a random variable hence mean will be changed but as we increase the sample size the mean will become closer to 10.

Check out the Examples given below to understand the variation in the Outputs as the sample size increases.

Example

The variation in the Outputs of mean of normal random variable created by using rnorm as the sample size increases is explained below −

mean(rnorm(100,mean=10))
mean(rnorm(100,mean=10))
mean(rnorm(100,mean=10))
mean(rnorm(100,mean=10))
mean(rnorm(100,mean=10))
mean(rnorm(100,mean=10))
mean(rnorm(100,mean=10))
mean(rnorm(1000,mean=10))
mean(rnorm(1000,mean=10))
mean(rnorm(1000,mean=10))
mean(rnorm(10000,mean=10))
mean(rnorm(10000,mean=10))
mean(rnorm(10000,mean=10))
mean(rnorm(10000,mean=10))
mean(rnorm(10000,mean=10))
mean(rnorm(100000,mean=10))
mean(rnorm(100000,mean=10))
mean(rnorm(100000,mean=10))
mean(rnorm(100000,mean=10))
mean(rnorm(100000,mean=10))
mean(rnorm(1000000,mean=10))
mean(rnorm(1000000,mean=10))
mean(rnorm(1000000,mean=10))
mean(rnorm(1000000,mean=10))
mean(rnorm(1000000,mean=10))
mean(rnorm(10000000,mean=10))
mean(rnorm(10000000,mean=10))
mean(rnorm(10000000,mean=10))
mean(rnorm(100000000,mean=10))

The Output is as follows

[1] 10.13626
[1] 9.892686
[1] 9.938534
[1] 9.918113
[1] 10.12262
[1] 10.05268
[1] 10.06714
[1] 9.953736
[1] 10.02104
[1] 9.973183
[1] 9.994081
[1] 10.00588
[1] 9.983589
[1] 10.00452
[1] 10.00093
[1] 9.999846
[1] 9.999979
[1] 9.996462
[1] 10.00455
[1] 10.00049
[1] 9.999261
[1] 9.998425
[1] 9.999633
[1] 10.00064
[1] 9.998785
[1] 10.00003
[1] 9.999948
[1] 9.99997
raja
Published on 05-Nov-2021 05:37:44

Advertisements