lfg.Rd
A Lagged Fibbonacci Generator (LFG or sometimes LFib) is an example of a pseudorandom number generator. This class of pseudorandom number generator is aimed at being an improvment of the 'standard' linear congruential generator. These are based on the generalization of the Fibbonacci sequence.
The Fibonacci sequence may be described by the recurrence relation:
\(S_n = S_{n-1}+S_{n-2}\)
Hence, the new term is the sum of the last two terms in the sequence This can be generalized by the sequence:
\(S_n \eqiv S_{n-j} \star S_{n-k} \space (\text{mod }m), 0 < j <k\)
In which case, the new term is some combination of any two previous terms. m is usually a power of 2 (m = 2M), often 232 or 264. The operator denotes a general binary operation. This may be either addition, subtraction, multiplication, or the bitwise exclusive-or operator (XOR). In this package, the operator denotes addition.The theory of this type of generator is rather complex, and it may not be sufficient simply to choose random values for j and k. These generators also tend to be very sensitive to initialisation.
lfg(n, j = 65L, k = 71L, bitsize = 32L)
\(j\) value specified. Note \(0 < j <k\).
\(k\) value specified. Note \(0 < j <k\).
maximum number of bits got \(m\)
n number of random numbers to generate.
For more information, see the Wikipedia page.
random_numbers <- lfg(10000)
# Plot numbers to see that they are random
plot(random_numbers)