java.lang.Object
io.github.olyutorskii.aletojio.rng.fibo.LagFib
All Implemented Interfaces:
RndInt32

public class LagFib extends Object implements RndInt32
Lagged Fibonacci Pseudo Random Generator(LFG).

Recurrence relation sequences : X(n) = X(n-j) + X(n-k)

If generation(1,2) given, it generates the so-called Fibonacchi numbers sequence.

Typical generation pairs.

  • (1,2)
  • (7,10)
  • (24,55)
  • (353,521)
  • (861,1279)
  • (9739,23209)

Seed values are mixed well if the number of generations(k,j) are prime to each other.

If polynomial: y = x**k + x**j + 1 is primitive over GF(2), generator has more long period.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    LagFib(int genYounger, int genOlder)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected int
    binOp(int tap1, int tap2)
    Binary operation between 2 taps.
    protected void
    checkSeeds(int... initVec)
    Check seeds.
    static boolean
    hasOdd(int... iVec)
    Check whether int array contains odd number or not.
    int
    Return next random number as 32bit int with random sign-bit.
    void
    setSeed(int... initVec)
    Set seed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait