Skip to main content

Pseudo-random number generator with Fibonacci sequence

\[ s_k = (k\cdot A) \bmod B\]

\(s_k\) is the pseudo-random number and \(A\) and \(B\) are prime numbers. \(k\) is in the range \(

\[0,B-1\]

\). If \(k\) is greater than \(B-1\), the results will be repeat as \(B\) is the period of the sequence. For example, \(A = 7\) and \(B = 17\). This sequence written in MATLAB could be:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
A = 7;
B = 17;
n = [];

t = 0:B;
for i=0:B
    n = [n mod(i*A,B)];
end

stem(t,n);
\[caption id="attachment\_1345" width="560"\]

Pseudo-random values

\[/caption\]\[caption id="attachment\_1346" width="560"\]

Periodicity of the sequence when k > B

\[/caption\]