Post Reply 
Looking for more algorithms for quasi-random numbers
11-29-2019, 01:06 PM (This post was last modified: 11-30-2019 06:16 AM by Namir.)
Post: #1
Looking for more algorithms for quasi-random numbers
Hi All Math Lovers,

In another thread of mine, ttw mentions quasi-random numbers. Quasi-random numbers (QRNs) present a better spread over a range of values than pseudo-random numbers (PRNs). On the other hand, QRNs will often fail randomness tests. They true purpose to to cover more uniformly a range of values in one of more dimensions.

This is part of ttw's response in my other thread, where he mentions QRNs:

Quote:The easiest multi-dimensional quasi-random sequence is the Richtmeyer sequence. One uses the fractional part of multiples of the square roots of primes. Sqrt(2), Sqrt(3), etc. It's quick to do these by just setting x(i)=0 updating by x(i)=Frac(x(i)+Sqrt(P(i))). Naturally one just stores the fractional parts of the irrationals and updates. (List mode). The sequence is also called the Kronecker or Weyl sequence at times.

The above text includes the algorithm of setting x(1)=0 updating by x(i)=Frac(x(i)+Sqrt(P(i))). The array of P() represents prime numbers starting with 2. You can change x(1) to had a uniform random number as a seed (to generate different sequences every time you apply the algorithm) or simply set x(1) = sqrt(P(1)) = sqrt(2).

I am curious about other formulas to calculate sequences of quasi-random numbers. You are welcome to use your imagination. My first attempt was something like:

Code:
n = number of x to generate
m = 100*n
Calculate P() for primes in the range of 1 to m
X(1) = rand or Frac(ln(P(3)) * sqrt(P(1))
j = 2
count = 0
for i=2 to n
  X(i) = Frac(X(i) + ln(P(j+1)) * sqrt(P(j-1))
  j = j + 1
  if j > m then
   count = count + 1
    j = 2 + count
  end
end

The above code produces x() with a mean near 0.5 and standard deviation near 0.28. The auto correlations for the first 50 lags are in the orde rof 10^(-2) to 10^(-4).

I am curious about other formulas to calculate sequences of quasi-random numbers. You are welcome to use your imagination. You can even commit math heresy!!! As long as it works, you are fine (and forgiven) :-)

Namir
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Looking for more algorithms for quasi-random numbers - Namir - 11-29-2019 01:06 PM



User(s) browsing this thread: 1 Guest(s)