fbpx
Wikipedia

Lagged Fibonacci generator

A Lagged Fibonacci generator (LFG or sometimes LFib) is an example of a pseudorandom number generator. This class of random number generator is aimed at being an improvement on the 'standard' linear congruential generator. These are based on a generalisation of the Fibonacci sequence.

The Fibonacci sequence may be described by the recurrence relation:

Hence, the new term is the sum of the last two terms in the sequence. This can be generalised to the sequence:

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). 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.

Generators of this type employ k words of state (they 'remember' the last k values).

If the operation used is addition, then the generator is described as an Additive Lagged Fibonacci Generator or ALFG, if multiplication is used, it is a Multiplicative Lagged Fibonacci Generator or MLFG, and if the XOR operation is used, it is called a Two-tap generalised feedback shift register or GFSR. The Mersenne Twister algorithm is a variation on a GFSR. The GFSR is also related to the linear-feedback shift register, or LFSR.

Properties of lagged Fibonacci generators Edit

The maximum period of lagged Fibonacci generators depends on the binary operation  . If addition or subtraction is used, the maximum period is (2k − 1) × 2M−1. If multiplication is used, the maximum period is (2k − 1) × 2M−3, or 1/4 of period of the additive case. If bitwise xor is used, the maximum period is 2k − 1.

For the generator to achieve this maximum period, the polynomial:

y = xk + xj + 1

must be primitive over the integers mod 2. Values of j and k satisfying this constraint have been published in the literature.

Popular pairs of primitive polynomial degrees[1][2]
j 7 5 24 65 128 6 31 97 353 168 334 273 418
k 10 17 55 71 159 31 63 127 521 521 607 607 1279

Another list of possible values for j and k is on page 29 of volume 2 of The Art of Computer Programming:

(24, 55), (38, 89), (37, 100), (30, 127), (83, 258), (107, 378), (273, 607), (1029, 2281), (576, 3217), (4187, 9689), (7083, 19937), (9739, 23209)

Note that the smaller number have short periods (only a few "random" numbers are generated before the first "random" number is repeated and the sequence restarts).

If addition is used, it is required that at least one of the first k values chosen to initialise the generator be odd. If multiplication is used, instead, it is required that all the first k values be odd, and further that at least one of them is ±3 mod 8.[3]

It has been suggested that good ratios between j and k are approximately the golden ratio.[4]

Problems with LFGs Edit

In a paper on four-tap shift registers, Robert M. Ziff, referring to LFGs that use the XOR operator, states that "It is now widely known that such generators, in particular with the two-tap rules such as R(103, 250), have serious deficiencies. Marsaglia observed very poor behavior with R(24, 55) and smaller generators, and advised against using generators of this type altogether. ... The basic problem of two-tap generators R(a, b) is that they have a built-in three-point correlation between  ,  , and  , simply given by the generator itself ... While these correlations are spread over the size   of the generator itself, they can evidently still lead to significant errors.".[5] This only refers to the standard LFG where each new number in the sequence depends on two previous numbers. A three-tap LFG has been shown to eliminate some statistical problems such as failing the Birthday Spacings and Generalized Triple tests.[4]

The initialization of LFGs is a very complex problem. The output of LFGs is very sensitive to initial conditions, and statistical defects may appear initially but also periodically in the output sequence unless extreme care is taken.[citation needed] Another potential problem with LFGs is that the mathematical theory behind them is incomplete, making it necessary to rely on statistical tests rather than theoretical performance.

Usage Edit

  • Freeciv uses a lagged Fibonacci generator with {j = 24, k = 55} for its random number generator.
  • The Boost library includes an implementation of a lagged Fibonacci generator.
  • Subtract with carry, a lagged Fibonacci generator engine, is included in the C++11 library.
  • The Oracle Database implements this generator in its DBMS_RANDOM package (available in Oracle 8 and newer versions).

See also Edit

Wikipedia page 'List of random number generators' lists other PRNGs including some with better statistical qualitites:

References Edit

, G.Marsaglia, A.Zaman
  1. ^ . www.ccs.uky.edu. Archived from the original on 9 March 2004. Retrieved 13 January 2022.
  2. ^ . Archived from the original on 2010-06-14. Retrieved 2005-04-11.
  3. ^ Parameterizing Parallel Multiplicative Lagged-Fibonacci Generators, M. Mascagni, A. Srinivasan
  4. ^ a b "Uniform random number generators for supercomputers", Richard Brent, 1992
  5. ^ "Four-tap shift-register-sequence random-number generators", Robert M. Ziff, Computers in Physics, 12(4), Jul/Aug 1998, pp. 385–392

lagged, fibonacci, generator, sometimes, lfib, example, pseudorandom, number, generator, this, class, random, number, generator, aimed, being, improvement, standard, linear, congruential, generator, these, based, generalisation, fibonacci, sequence, fibonacci,. A Lagged Fibonacci generator LFG or sometimes LFib is an example of a pseudorandom number generator This class of random number generator is aimed at being an improvement on the standard linear congruential generator These are based on a generalisation of the Fibonacci sequence The Fibonacci sequence may be described by the recurrence relation S n S n 1 S n 2 displaystyle 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 generalised to the sequence S n S n j S n k mod m 0 lt j lt k displaystyle S n equiv S n j star S n k pmod m 0 lt j lt 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 displaystyle star operator denotes a general binary operation This may be either addition subtraction multiplication or the bitwise exclusive or operator XOR 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 Generators of this type employ k words of state they remember the last k values If the operation used is addition then the generator is described as an Additive Lagged Fibonacci Generator or ALFG if multiplication is used it is a Multiplicative Lagged Fibonacci Generator or MLFG and if the XOR operation is used it is called a Two tap generalised feedback shift register or GFSR The Mersenne Twister algorithm is a variation on a GFSR The GFSR is also related to the linear feedback shift register or LFSR Contents 1 Properties of lagged Fibonacci generators 2 Problems with LFGs 3 Usage 4 See also 5 ReferencesProperties of lagged Fibonacci generators EditThe maximum period of lagged Fibonacci generators depends on the binary operation displaystyle star nbsp If addition or subtraction is used the maximum period is 2k 1 2M 1 If multiplication is used the maximum period is 2k 1 2M 3 or 1 4 of period of the additive case If bitwise xor is used the maximum period is 2k 1 For the generator to achieve this maximum period the polynomial y xk xj 1must be primitive over the integers mod 2 Values of j and k satisfying this constraint have been published in the literature Popular pairs of primitive polynomial degrees 1 2 j 7 5 24 65 128 6 31 97 353 168 334 273 418k 10 17 55 71 159 31 63 127 521 521 607 607 1279Another list of possible values for j and k is on page 29 of volume 2 of The Art of Computer Programming 24 55 38 89 37 100 30 127 83 258 107 378 273 607 1029 2281 576 3217 4187 9689 7083 19937 9739 23209 Note that the smaller number have short periods only a few random numbers are generated before the first random number is repeated and the sequence restarts If addition is used it is required that at least one of the first k values chosen to initialise the generator be odd If multiplication is used instead it is required that all the first k values be odd and further that at least one of them is 3 mod 8 3 It has been suggested that good ratios between j and k are approximately the golden ratio 4 Problems with LFGs EditIn a paper on four tap shift registers Robert M Ziff referring to LFGs that use the XOR operator states that It is now widely known that such generators in particular with the two tap rules such as R 103 250 have serious deficiencies Marsaglia observed very poor behavior with R 24 55 and smaller generators and advised against using generators of this type altogether The basic problem of two tap generators R a b is that they have a built in three point correlation between x n displaystyle x n nbsp x n a displaystyle x n a nbsp and x n b displaystyle x n b nbsp simply given by the generator itself While these correlations are spread over the size p m a x a b c displaystyle p max a b c ldots nbsp of the generator itself they can evidently still lead to significant errors 5 This only refers to the standard LFG where each new number in the sequence depends on two previous numbers A three tap LFG has been shown to eliminate some statistical problems such as failing the Birthday Spacings and Generalized Triple tests 4 The initialization of LFGs is a very complex problem The output of LFGs is very sensitive to initial conditions and statistical defects may appear initially but also periodically in the output sequence unless extreme care is taken citation needed Another potential problem with LFGs is that the mathematical theory behind them is incomplete making it necessary to rely on statistical tests rather than theoretical performance Usage EditFreeciv uses a lagged Fibonacci generator with j 24 k 55 for its random number generator The Boost library includes an implementation of a lagged Fibonacci generator Subtract with carry a lagged Fibonacci generator engine is included in the C 11 library The Oracle Database implements this generator in its DBMS RANDOM package available in Oracle 8 and newer versions See also EditWikipedia page List of random number generators lists other PRNGs including some with better statistical qualitites Linear congruential generator ACORN generator Mersenne Twister Xoroshiro128 FISH cipher Pike VIC cipherReferences EditToward a universal random number generator G Marsaglia A Zaman RN Chapter www ccs uky edu Archived from the original on 9 March 2004 Retrieved 13 January 2022 SPRNG Scalable Parallel Pseudo Random Number Generator Library Archived from the original on 2010 06 14 Retrieved 2005 04 11 Parameterizing Parallel Multiplicative Lagged Fibonacci Generators M Mascagni A Srinivasan a b Uniform random number generators for supercomputers Richard Brent 1992 Four tap shift register sequence random number generators Robert M Ziff Computers in Physics 12 4 Jul Aug 1998 pp 385 392 Retrieved from https en wikipedia org w index php title Lagged Fibonacci generator amp oldid 1120471109, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.