lundi 23 mai 2016

Why runif function in r doesn't really generate random numbers?

I am trying to generate a set of random numbers. It is very straight-forward:

start <- 1e-9
end <- 1e9

# centered by 1

for (i in 1:20) {
   par <- runif(10000, start, end)
   print(summary(par))
}

     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
72230 244400000 493900000 496400000 751500000 999800000 
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
1.016e+05 2.505e+08 4.985e+08 5.001e+08 7.475e+08 1.000e+09 
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
6.333e+04 2.494e+08 5.031e+08 4.997e+08 7.495e+08 1.000e+09 
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
33970 242600000 489700000 491600000 738900000 999800000 
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
1.476e+04 2.485e+08 4.992e+08 4.980e+08 7.449e+08 1.000e+09 
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
64630 252600000 500500000 500600000 750400000 999800000 
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
2.825e+05 2.556e+08 5.010e+08 5.021e+08 7.512e+08 1.000e+09 
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
6.824e+04 2.498e+08 4.975e+08 5.006e+08 7.505e+08 1.000e+09 
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
127400 252200000 497400000 501500000 754300000 999900000 

By setting up an range centered by 1, I was expecting an roughly even numbers of samples that is below 1. However, it seems all generated samples are well above 1. Why 'runif()' didn't go below 1 as I expected?




Aucun commentaire:

Enregistrer un commentaire