I have written this code :
for i=1:m-1
x(i+1)=mod(a*x(i)+c,m)
x(i)=x(i+1)
end
But I don't know how to write lcg as a function that generates random numbers.
LCG is a linear congruential generator which is one of the oldest and best-known pseudorandom number generator algorithms. The generator is defined by the recurrence relation:
Xn+1 =(aXn + c) mod m
,and I want to write a function for this relation.