OFFSET
0,6
COMMENTS
Exclusive or (XOR) is a natural operation for computers. When combined with delayed feedback it can yield very complex behavior, which can be utilized for pseudorandom number generation [Marsaglia 2003]. Such "linear-feedback shift register" schemes can be implemented with basic computer operations and are hence very fast. Their behavior is typically periodic with long periods. Analogous procedures are used to generate this sequence, which takes a delayed feedback XOR and adds 1 at each iteration. It appears to be growing, although existence of loops has not been excluded.
LINKS
G. Marsaglia, Xorshift RNGs, Journal of Statistical Software, Vol. 8, Issue 14, Jul 2003.
Wikipedia, Bitwise operation (XOR).
Wikipedia, Linear-feedback shift register.
Wikipedia, Xorshift.
EXAMPLE
a(4) = (a(3) XOR a(0)) + 1 = (0 XOR 0) + 1 = 0 + 1 = 1.
a(5) = (a(4) XOR a(1)) + 1 = (1 XOR 0) + 1 = 1 + 1 = 2.
a(8) = (a(7) XOR a(4)) + 1 = (100_2 XOR 001_2) + 1 = 101_2 + 1 = 110_2 = 6_10.
MATHEMATICA
Nest[Append[#, 1 + BitXor @@ #[[{-1, -4}]] ] &, ConstantArray[0, 4], 75] (* Michael De Vlieger, Feb 23 2020 *)
PROG
(Python)
feedback_delay = 3
a = [0 for i in range(feedback_delay+1)]
for i in range(feedback_delay, 100):
a.append((a[i]^a[i-feedback_delay])+1)
CROSSREFS
KEYWORD
AUTHOR
Rok Cestnik, Feb 23 2020
STATUS
approved