Kiss

KISS (from George Marsaglia)

The idea is to use simple, fast, individually promising generators to get a composite that will be fast, easy to code have a very long period and pass all the tests put to it. The three components of KISS are

x(n)=a*x(n-1)+1 mod 2^32
y(n)=y(n-1)(I+L^13)(I+R^17)(I+L^5),
z(n)=2*z(n-1)+z(n-2) +carry mod 2^32

The y's are a shift register sequence on 32bit binary vectors period 2^32-1; The z's are a simple multiply-with-carry sequence with period 2^63+2^32-1. The period of KISS is thus

2^32*(2^32-1)*(2^63+2^32-1) > 2^127

Note that this should be passed by reference, unless you really intend to provide a local copy to a callee

Members

Aliases

toInt
alias toInt = natural
toReal
alias toReal = fraction

Functions

fraction
double fraction()

Returns a value in the range [0, 1) using 32 bits of precision (with thanks to Dr Jurgen A Doornik)

fractionEx
double fractionEx()

Returns a value in the range [0, 1) using 52 bits of precision (with thanks to Dr Jurgen A Doornik)

natural
uint natural()

Returns X such that 0 <= X <= uint.max

natural
uint natural(uint max)

Returns X such that 0 <= X < max

natural
uint natural(uint min, uint max)

Returns X such that min <= X < max

seed
void seed()

Seed the generator with current time

seed
void seed(uint seed)

Seed the generator with a provided value

Static functions

opCall
Kiss opCall()

Creates and seeds a new generator with the current time

Static variables

instance
Kiss instance;

A global, shared instance, seeded via startup time

Meta