This is satisfied by X 0 ≡ 41 (mod 64), so if we start with that, then X n ≡ X 0 − Y n (mod 256) for all n.įor example, using X 0 = 233 = 3×64 + 41: : 10-11 The sign is determined by c ≡ ☑ (mod 4), and the constant X 0 is determined by 1 ∓ c ≡ (1 − a) X 0 (mod m).Īs a simple example, consider the generators X n+1 = 157 X n + 3 mod 256 and Y n+1 = 157 Y n + 1 mod 256 i.e. With this choice of X 0, X n = X 0 ± Y n will remain true for all n. In the common case where m is a power of 2 and a ≡ 5 (mod 8) (a desirable property for other reasons), it is always possible to find an initial value X 0 so that the denominator X 1 − X 0 ≡ ☑ (mod m), producing an even simpler relationship. The generator is defined by the recurrence relation: The theory behind them is relatively easy to understand, and they are easily implemented and fast, especially on computer hardware which can provide modular arithmetic by storage-bit truncation. The method represents one of the oldest and best-known pseudorandom number generator algorithms. Ī linear congruential generator ( LCG) is an algorithm that yields a sequence of pseudo-randomized numbers calculated with a discontinuous piecewise linear equation. Using a = 4 and c = 1 (bottom row) gives a cycle length of 9 with any seed in. The second row is the same generator with a seed of 3, which produces a cycle of length 2. The top row shows a generator with m = 9, a = 2, c = 0, and a seed of 1, which produces a cycle of length 6. Each row shows the state evolving until it repeats. Algorithm for generating pseudo-randomized numbers Two modulo-9 LCGs show how different parameters lead to different cycle lengths.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |