Write a program to demonstrate that for a linear congruential generator with modulus đ = 2 đ and constant đ = 1, in order to achieve the full period, the multiplier đ must be equal to 4đŸ + 1. Consider đ =5, 7, and 10; and đŸ =2 and 9. You should also consider two values of the multiplier that do not match this.
My problem with this is that I have the code to run this in Python. The suggestions I have been given are
def lcg(modulus, a, c, seed):
"""Linear congruential generator."""
while True:
seed = (a * seed + c) % modulus
yield seed
However, the problem does not mention the seed value, nor do I know how to tell if it will achieve a full period. Any guidance would be appreciated
Aucun commentaire:
Enregistrer un commentaire