0

I am interested in learning more about Random Number Generation. Recently, I found out about an algorithm called "RANDU" (https://en.wikipedia.org/wiki/RANDU), which was an early algorithm for generating random numbers.

Using the R language, I implemented it below:

v = rep(0,100)
v[1]=3
for (j in 1:100) {
v[j+1]=(65539*v[j])%%(2^31)
}
i = 1:101

range01 <- function(x, ...){(x - min(x, ...)) / (max(x, ...) - min(x, ...))}

rand_data = data.frame(i,v)
rand_data<span class="math-container">$int_version = range01(rand_data$</span>v)

head(rand_data) i v int_version 1 1 3 0.000000e+00 2 2 196617 9.201486e-05 3 3 1179675 5.520835e-04 4 4 5308497 2.484362e-03 5 5 21233907 9.937413e-03 6 6 79626969 3.726522e-02

plot(rand_data$v, type = "b", main = "100 Random Real Numbers with Randu")

enter image description here

Naturally, this lead me to the following question:

  • How do we know that these 100 numbers are truly random - Is there some mathematical proof for this?
  • Why does this RANDU algorithm work - Is there some mathematical proof for this?

I tried to look into this, but I couldn't find a straight answer. Can someone please provide any comments?

Thank you!

Note: Apparently you can use the Chi-Square Test to find out if a random sequence of numbers has a "uniform distribution" (https://stats.stackexchange.com/questions/406406/test-of-uniform-distribution-using-ks-test-and-chi-square-in-r, Is there a simple test for uniform distributions? ... but I am not sure why the Chi-Square Test can detect if random numbers have a uniform distribution). I performed this test in R:

ks.test(rand_data$int_version, "punif", min(rand_data$int_version), max(rand_data$int_version))
One-sample Kolmogorov-Smirnov test

data: rand_data$int_version D = 0.079507, p-value = 0.5457 alternative hypothesis: two-sided

Based on these results, the p-value is significantly greater than a standard tolerance level (e.g. alpha = 0.05) - therefore, there is sufficient statistical evidence to accept the Null Hypothesis and conclude that these random numbers correspond to a uniform distribution.

stats_noob
  • 3,112
  • 4
  • 10
  • 36
  • 1
    R... aka Rhit.... – the_candyman May 28 '22 at 20:03
  • 3
    They are not truly random, but instead pseudo-random. And the algorithm has flaws such as that illustrated in the 3D plot in the Wikipedia article – Henry May 28 '22 at 20:04
  • 2
    Even defining what it means to be "random" is very tricky, but, being a deterministic process, we usually don't call it random. – Thomas Andrews May 28 '22 at 20:05
  • 4
    Knuth, The Art of Computer Programming: RANDU is a linear congruential random number generator, and a pretty bad one at that. – gnasher729 May 28 '22 at 20:19
  • @ Henry: Thank you for your reply! I am having some trouble understanding the difference between pseudo-random and random numbers. It seems like pseudo-random numbers are random numbers that are generated using a deterministic machine (e.g. a computer), and this is implies that there might be some room for "non-randomness" ... but truly random are generated from some non-deterministic process (e.g. decimal numbers in atmospheric pressure readings) and are generally considered to be more "random". Is this correct? – stats_noob May 29 '22 at 02:55
  • @ Henry: I read the Wikipedia article and also read that this algorithm has flaws, but I was not able to fully understand these flaws and why these flaws are produced. Could you please help me understand this? Thank you so much! – stats_noob May 29 '22 at 02:56
  • @ Thomas Andrews: Thank you for your reply! "a deterministic process, we usually don't call it random" - why is this so? Thank you! – stats_noob May 29 '22 at 02:57
  • @ gnasher729: Thank you for your reply! Can you please explain why RANDU is not good? thank you so much! – stats_noob May 29 '22 at 02:58
  • @the_candyman : haha! – stats_noob May 29 '22 at 02:58
  • @ Moo: this looks very complicated! – stats_noob May 29 '22 at 02:58
  • 1
    pick a book on pseudorandom numbers, it will clarify all your questions, by example the book of Oded Goldreich – Masacroso May 29 '22 at 06:57
  • @ Masacroso: Thank you! I will look into it! – stats_noob May 30 '22 at 02:32

0 Answers0