– Typee Documentation –
5 – Typee Built-in Libraries
5.Random Library
Path Libs/Random/
.
This library provides many Pseudo-Random Generators (PRG) with different long to very long periods, different memory allocations, very short time calculations and far better results according to their evaluation from TestU01 [1] than the Mersenne-Twister PRG that is implemented by default in most of the modern programming languages. Programmers are strongly encouraged to use this library rather than the ones implemented in targeted programming languages.
[1]: Pierre L’Ecuyer and Richard Simard (Université de Montreal), in ‘TestU01: A C Library for Empirical Testing of Random Number Generator’, ACM Transactions on Mathematical Software, vol.33 n.4, pp.22-40, August 2007.
Every PRG that are availalble in the built-in library Random
evaluate pseudo-random suites with numbers uniformely distributed within interval [0.0, 1.0).
language available since Typee version pure Typee 1.0
Generalities
The software architecture of this library is simple:
- each module contains the definition of one PRG, and
- an internal package named
Bases
contains all the base classes – there are a few base classes…
The core of the generation of the pseudo-random numbers suites is mainly contained in the base classes. The upper modules in the directories hierarchy are mainly interfaces to Typee programs.
To understand the characteristics of each provided PRG, have a look to this current section of Typee documentation (well, contained in this page) and have a look also to the code of each module: a long documentation about their specifications is provided for each of them. You will get access to this code in Typee GitHub repository: https://github.com/Typee-Language/Typee/tree/master/src/Libs/Random.
Important Notice: None of these PRG should be used for cryptographic applications or for random games based on money. They all are known to be predictable!
They nevertheless are very useful for simulations and have amazing performances in randomness generation and speed of calculation.
Notice: For serious simulation applications, prefer to use the best-results PRG with the longer periods. They all are fast to compute and do not allocate that much space for their internal resources in memory. Meanwhile, avoid to use the Mersenne-Twister default PRG provided with your favorite programming language. This is a slow to compute PRG (it uses many shifts for the evaluation of next numbers) and it fails passing some of the TestU01 tests while the all the best PRG we provide here pass all those tests (except the two simplest ones).
We first present here the different modules available in this library: one module, one PRG. We then present the underlying modules, i.e. the ones that contain the base classes and the pseudo-random generation process that all previous modules depend on.
Here are the different PRG available in this built-in library Random
, and their comparisons.
In the next table, small-, medium- and big- fails relate to the diffculty of the tests they relate to. The biggest the difficulty, the better the PRG is when proving no failure.
(source: [1] – see above)
class | TU01 name | Memory Usage | Period | time- 32bits | time- 64bits | Small fails |
Medium fails | Big fails |
---|---|---|---|---|---|---|---|---|
Rand32 | LCG(232, 69069, 1) | 1 x 4-bytes | 232 | 3.20 | 0.67 | 11 | 106 | *too many* |
Rand63 | LCG(263, 9219741426499971445, 1) | 2 x 4-bytes | 263 | 4.20 | 0.75 | 0 | 5 | 7 |
Rand78 | LFib(264, 17, 5, +) | 34 x 4-bytes | 278 | n.a. | 1.1 | 0 | 0 | 0 |
Rand116 | LFib(264, 55, 24, +) | 110 x 4-bytes | 2116 | n.a. | 1.0 | 0 | 0 | 0 |
Rand287 | Marsa-LFIB4 | 256 x 4-bytes | 2287 | 3.40 | 0.8 | 0 | 0 | 0 |
Rand668 | LFib(264, 607, 273, +) | 1,214 x 4-bytes | 2668 | n.a. | 0.9 | 0 | 0 | 0 |
Rand1340 | LFib(264, 1279, 861, +) | 2,558 x 4-bytes | 21,340 | n.a. | 0.9 | 0 | 0 | 0 |
Rand1457 | DX-47-3 | 47 x 4-bytes | 21,457 | n.a. | 1.4 | 0 | 0 | 0 |
Rand49507 | DX-1597-2-7 | 1,597 x 4-bytes | 249,507 | n.a. | 1.4 | 0 | 0 | 0 |
module rand32.ty
Contains the definition of class Rand32
.
This is the most simple pseudo-random generator. It is based on a Linear Congruantial Generator (LCG) and is known to provide the worst results in terms of randomness.
Do not hesitate to use it for a dice-rolling application or for small games on small devices. It will correctly do the job with the less allocated resources in memory. Meanwhile, do not use it for serious or complicated simulation applications.
LCG models evaluate pseudo-random numbers suites xi as a simple mathematical function of
xi = ( a . xi-1 + c ) mod m
The implementation of this LCG 32-bits model is based on (a=69069, c=1) since these two values have evaluated to be the ‘best’ ones for LCGs within TestU01 while m = 232. Its period is about 232 (i.e. about 4.3×109), which is the length of the pseudo-random suites before it repeats itself.
See Rand63
for a 263 (i.e. about 9.2×1018) period LC-Generator with low computation time also, longer period and really better randomness characteristics than with Rand32
.
Furthermore this class is callable:
Rand32 rand = Rand32(); print( rand() ); // prints a uniform pseudo-random value within [0.0, 1.0) print( rand(a) ); // prints a uniform pseudo-random value within [0.0, a) print( rand(a,b) ); // prints a uniform pseudo-random value within [a , b)
For simulating the roll of a dice you should program:
Rand32 diceRoll = Rand32(); print( uint8(diceRoll(1, 7)) ); // prints a uniform roll within set {1, 2, 3, 4, 5, 6}
Rand32()
Rand32( const ? in (uint32,float32,float64) seed_value )
Constructors.
seed_value
is used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for seed. This allows the processing again of a same pseudo-random suite.
When seed_value
is not provided as an argument, the System time is used instead to evaluate a seed_value. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
none set_state()
none set_state( const ? in (uint32,float32,float64) seed_value )
Sets the value of a seed to initiate the next pseudo-random suite.
seed_value
is used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for seed. This allows the processing again of a same pseudo-random suite.
When seed_value
is not provided as an argument, the System time is used instead to evaluate a seed_value. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
const uint32 get_state()
Returns the current internal state of the PRG. This is a simple unsigned 32-bit integer. This value may be later used to set again the internal state of the PRG with this same value and generate then again the same pseudo-random suite of numbers.
const float64 operator () ()
Returns a pseudo-random value in interval: [0.0, 1.0)
. This is the default signature used if the type of the expected returned value cannot be evaluated at translation time.
const int8 operator () ()
const int16 operator () ()
const int32 operator () ()
const int64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0x7f)
.
[0, 0x7fff)
.
[0, 0x7fff_ffff)
.
[0, 0x7fff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _int_
(i.e. of any signed integer type), the signature with const int32
is used.
const uint8 operator () ()
const uint16 operator () ()
const uint32 operator () ()
const uint64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0xff)
.
[0, 0xffff)
.
[0, 0xffff_ffff)
.
[0, 0xffff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _uint_
, the signature with const uint32
is used.
const float64 operator () ( const float64 b )
const int64 operator () ( const int64 b )
const uint64 operator () ( const uint64 b )
Returns a pseudo-random value in interval: [0, b)
if b > 0
and [b, 0)
otherwise.
const float64 operator () ( const float64 a, const float64 b )
const int64 operator () ( const int64 a, const int64 b )
const uint64 operator () ( const uint64 a, const uint64 b )
Returns a pseudo-random value in interval: [a, b)
if a >= b
and [b, a)
otherwise.
module rand63.ty
Contains the definition of class Rand63
.
This is one of the most simple pseudo-random generators. It is based on a Linear Congruantial Generator (LCG) and is known to provide not that good results in terms of randomness.
Do not hesitate to use it for a dice-rolling application or for small games on small devices. It will correctly do the job with the less allocated resources in memory. Meanwhile, do not use it for serious or complicated simulation applications.
LCG models evaluate pseudo-random numbers suites xi as a simple mathematical function of
xi = ( a . xi-1 + c ) mod m
The implementation of this LCG 63-bits model is based on (a=9_219_741_426_499_971_445, c=1) since these two values have evaluated to be the ‘best’ ones for LCGs within TestU01 while m = 263. Its period is about 263 (i.e. about 9.2×1018), which is the length of the pseudo-random suites before it repeats itself.
See Rand32
for a 232 (i.e. 4.3×109) period LC-Generator with very low computation time but shorter period and worse randomness characteristics than for Rand63
.
Furthermore this class is callable:
Rand63 rand = Rand63 (); print( rand() ); // prints a uniform pseudo-random value within [0.0, 1.0) print( rand(a) ); // prints a uniform pseudo-random value within [0.0, a) print( rand(a,b) ); // prints a uniform pseudo-random value within [a , b)
For simulating the roll of a dice you should program:
Rand63 diceRoll = Rand63 (); print( uint8(diceRoll(1, 7)) ); // prints a uniform roll within set {1, 2, 3, 4, 5, 6}
Rand63()
Rand63( const ? in (uint64,float32,float64) seed_value )
Constructors.
seed_value
is used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for seed. This allows the processing again of a same pseudo-random suite.
When seed_value
is not provided as an argument, the System time is used instead to evaluate a seed_value. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
none set_state()
none set_state( const ? in (uint64,float32,float64) seed_value )
Sets the value of a seed to initiate the next pseudo-random suite.
seed_value
is used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for seed. This allows the processing again of a same pseudo-random suite.
When seed_value
is not provided as an argument, the System time is used instead to evaluate a seed_value. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
const uint64 get_state()
Returns the current internal state of the PRG. This is a simple unsigned 64-bit integer. This value may be later used to set again the internal state of the PRG with this same value and generate then again the same pseudo-random suite of numbers.
const float64 operator () ()
Returns a pseudo-random value in interval: [0.0, 1.0)
. This is the default signature used if the type of the expected returned value cannot be evaluated at translation time.
const int8 operator () ()
const int16 operator () ()
const int32 operator () ()
const int64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0x7f)
.
[0, 0x7fff)
.
[0, 0x7fff_ffff)
.
[0, 0x7fff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _int_
(i.e. of any signed integer type), the signature with const int64
is used.
const uint8 operator () ()
const uint16 operator () ()
const uint32 operator () ()
const uint64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0xff)
.
[0, 0xffff)
.
[0, 0xffff_ffff)
.
[0, 0xffff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _uint_
(i.e. of any signed integer type), the signature with const uint64
is used.
const float64 operator () ( const float64 b )
const int64 operator () ( const int64 b )
const uint64 operator () ( const uint64 b )
Returns a pseudo-random value in interval: [0, b)
if b > 0
and [b, 0)
otherwise.
const float64 operator () ( const float64 a, const float64 b )
const int64 operator () ( const int64 a, const int64 b )
const uint64 operator () ( const uint64 a, const uint64 b )
Returns a pseudo-random value in interval: [a, b)
if a >= b
and [b, a)
otherwise.
module rand78.ty
Contains the definition of class Rand78
.
This is a fast 64-bits Lagged Fibonacci Generator (LFib) with a quite short period (3.0×1023).
Lagged Fibonacci generators LFib( m, r, k, op) use the recurrence
xi = ( xi-r op xi-k ) mod m
where op is an operation that can be:
+ (addition),
– (substraction),
* (multiplication),
^ (bitwise exclusive-or).
With the + or – operation, such generators are in fact MRGs (for Multiple Recursive Generators, which are explained later in this page). They offer very large periods with the best known results in the evaluation of their randomness. It is recommended to use such pseudo-random numbers generators rather than LCG ones for serious simulation applications.
The implementation of this LFib 64-bits model is based on a Lagged Fibonacci generator (LFIB) that uses the recurrence
xi = ( xi-5 + xi-17 ) mod 264
and offers a period of about 278 – i.e. 3.0×1023 – with low computation time due to the use of a 264 modulo and few memory space consumption (17 long integers).
Notice that the TestUO1 article states that the operator should be ‘*’ while Mascagni & Srinivasan in their original article stated that the operator is ‘+’. We’ve implemented here the original operator: ‘+’.
See Rand116
, Rand668
and Rand1340
for long period LFib generators (resp. 2116, 2668 and 21340 periods, i.e. resp. 8.3×1034, 1.2×10201 and 2.4×10403 periods) while same computation time and far higher precision (64-bits calculations) than MRGs, but a greater memory consumption (resp. 55, 607 and 1279 integers).
This class and all its inheriting sub-classes are callable.
Example:
Rand78 rand = Rand78(); print( rand() ); // prints a uniform pseudo-random value within [0.0, 1.0) print( rand(a) ); // prints a uniform pseudo-random value within [0.0, a) print( rand(a,b) ); // prints a uniform pseudo-random value within [a , b)
For simulating the roll of a dice you should program:
Rand78 diceRoll = Rand78(); print( uint8(diceRoll(1, 7)) ); // prints a uniform roll within set {1, 2, 3, 4, 5, 6}
Rand78()
Rand78( const InternalState seed_state )
Constructors.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
none set_state()
none set_state( const InternalState seed_value )
Sets the value of a seed to initiate the next pseudo-random suite.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
InternalState get_state()
Returns the current internal state of the PRG. This state may be later used to set again the internal state of the PRG with this same value and generate then again the same pseudo-random suite of numbers.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
const float64 operator () ()
Returns a pseudo-random value in interval: [0.0, 1.0)
. This is the default signature used if the type of the expected returned value cannot be evaluated at translation time.
const int8 operator () ()
const int16 operator () ()
const int32 operator () ()
const int64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0x7f)
.
[0, 0x7fff)
.
[0, 0x7fff_ffff)
.
[0, 0x7fff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _int_
(i.e. of any signed integer type), the signature with const int64
is used.
const uint8 operator () ()
const uint16 operator () ()
const uint32 operator () ()
const uint64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0xff)
.
[0, 0xffff)
.
[0, 0xffff_ffff)
.
[0, 0xffff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _uint_
(i.e. of any signed integer type), the signature with const uint64
is used.
const float64 operator () ( const float64 b )
const int64 operator () ( const int64 b )
const uint64 operator () ( const uint64 b )
Returns a pseudo-random value in interval: [0, b)
if b > 0
and [b, 0)
otherwise.
const float64 operator () ( const float64 a, const float64 b )
const int64 operator () ( const int64 a, const int64 b )
const uint64 operator () ( const uint64 a, const uint64 b )
Returns a pseudo-random value in interval: [a, b)
if a >= b
and [b, a)
otherwise.
module rand116.ty
Contains the definition of class Rand116
.
This a fast 64-bits Lagged Fibonacci Generator (LFib) with a quite short period (8.3×1034).
Lagged Fibonacci generators LFib( m, r, k, op) use the recurrence
xi = ( xi-r op xi-k ) mod m
where op is an operation that can be:
+ (addition),
– (substraction),
* (multiplication),
^ (bitwise exclusive-or).
With the + or – operation, such generators are in fact MRGs. They offer very large periods with the best known results in the evaluation of their randomness. It is recommended to use such pseudo-random numbers generators rather than LCG ones for serious simulation applications.
The implementation of this LFib 64-bits model is based on a Lagged Fibonacci generator (LFIB) that uses the recurrence
xi = ( xi-24 + xi-55 ) mod 264
and offers a period of about 2116 – i.e. 8.3×1034 – with low computation time due to the use of a 264 modulo and little space consumption (55 long integers).
Notice that the TestUO1 article states that the operator should be ‘*’ while Mascagni & Srinivasan in their original article stated that the operator is ‘+’. We’ve implemented here the original operator: ‘+’.
See Rand78
, Rand668
and Rand1340
for long period LFib generators (resp. 278, 2668 and 21340 periods, i.e. resp. 3.0×1023, 1.2×10201 and 2.4×10403 periods) while same computation time and far higher precision (64-bits calculations) than MRGs, but memory consumption (resp. 17, 607 and 1279 integers).
This class and all its inheriting sub-classes are callable.
Example:
Rand116 rand = Rand116(); print( rand() ); // prints a uniform pseudo-random value within [0.0, 1.0) print( rand(a) ); // prints a uniform pseudo-random value within [0.0, a) print( rand(a,b) ); // prints a uniform pseudo-random value within [a , b)
For simulating the roll of a dice you should program:
Rand116 diceRoll = Rand116(); print( uint8(diceRoll(1, 7)) ); // prints a uniform roll within set {1, 2, 3, 4, 5, 6}
Rand116()
Rand116( const InternalState seed_state )
Constructors.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
none set_state()
none set_state( const InternalState seed_value )
Sets the value of a seed to initiate the next pseudo-random suite.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
InternalState get_state()
Returns the current internal state of the PRG. This state may be later used to set again the internal state of the PRG with this same value and generate then again the same pseudo-random suite of numbers.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
const float64 operator () ()
Returns a pseudo-random value in interval: [0.0, 1.0)
. This is the default signature used if the type of the expected returned value cannot be evaluated at translation time.
const int8 operator () ()
const int16 operator () ()
const int32 operator () ()
const int64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0x7f)
.
[0, 0x7fff)
.
[0, 0x7fff_ffff)
.
[0, 0x7fff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _int_
(i.e. of any signed integer type), the signature with const int64
is used.
const uint8 operator () ()
const uint16 operator () ()
const uint32 operator () ()
const uint64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0xff)
.
[0, 0xffff)
.
[0, 0xffff_ffff)
.
[0, 0xffff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _uint_
(i.e. of any signed integer type), the signature with const uint64
is used.
const float64 operator () ( const float64 b )
const int64 operator () ( const int64 b )
const uint64 operator () ( const uint64 b )
Returns a pseudo-random value in interval: [0, b)
if b > 0
and [b, 0)
otherwise.
const float64 operator () ( const float64 a, const float64 b )
const int64 operator () ( const int64 a, const int64 b )
const uint64 operator () ( const uint64 a, const uint64 b )
Returns a pseudo-random value in interval: [a, b)
if a >= b
and [b, a)
otherwise.
module rand287.ty
Contains the definition of class Rand287
.
This a fast 32-bits Multiple Recursive Generator (MRG) with a long period (2.49×1086).
MRGs offer very large periods with the best known results in the evaluation of their randomness, as stated in the evaluation done by Pierre L’Ecuyer and Richard Simard (Université de Montreal) in TestU01.
Multiple Recursive Generators (MRGs) use the recurrence:
xi = [ A x sumj( xi-kj ) ] mod m
The implementation of this MRG 32-bits model is based on a Lagged Fibonacci generator (LFIB), the Marsa-LFIB4 one. The Marsa-LIBF4 version uses the recurrence
xi = ( xi-55 + xi-119 + xi-179 + xi-256 ) mod 232
and offers a period of about 2287 – i.e. 2.49×1086 – with low computation time due
to the use of a 232 modulo.
See Rand1457
for a longer period MR-Generator (21,457, i.e. 4.0×10438) and longer computation time (231-1 modulus calculations) but less memory space consumption (47 integers).
See Rand49507
for a far longer period (249,507, i.e. 1.2×1014,903 with low computation time too (31-bits modulus) but use of more memory space (1,597 integers).
This class and all its inheriting sub-classes are callable.
Example:
Rand287 rand = Rand287(); print( rand() ); // prints a uniform pseudo-random value within [0.0, 1.0) print( rand(a) ); // prints a uniform pseudo-random value within [0.0, a) print( rand(a,b) ); // prints a uniform pseudo-random value within [a , b)
For simulating the roll of a dice you should program:
Rand287 diceRoll = Rand287(); print( uint8(diceRoll(1, 7)) ); // prints a uniform roll within set {1, 2, 3, 4, 5, 6}
Rand287()
Rand287( const InternalState seed_state )
Constructors.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
none set_state()
none set_state( const InternalState seed_value )
Sets the value of a seed to initiate the next pseudo-random suite.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
InternalState get_state()
Returns the current internal state of the PRG. This state may be later used to set again the internal state of the PRG with this same value and generate then again the same pseudo-random suite of numbers.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
const float64 operator () ()
Returns a pseudo-random value in interval: [0.0, 1.0)
. This is the default signature used if the type of the expected returned value cannot be evaluated at translation time.
const int8 operator () ()
const int16 operator () ()
const int32 operator () ()
const int64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0x7f)
.
[0, 0x7fff)
.
[0, 0x7fff_ffff)
.
[0, 0x7fff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _int_
(i.e. of any signed integer type), the signature with const int32
is used.
const uint8 operator () ()
const uint16 operator () ()
const uint32 operator () ()
const uint64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0xff)
.
[0, 0xffff)
.
[0, 0xffff_ffff)
.
[0, 0xffff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _uint_
(i.e. of any signed integer type), the signature with const uint32
is used.
const float64 operator () ( const float64 b )
const int64 operator () ( const int64 b )
const uint64 operator () ( const uint64 b )
Returns a pseudo-random value in interval: [0, b)
if b > 0
and [b, 0)
otherwise.
const float64 operator () ( const float64 a, const float64 b )
const int64 operator () ( const int64 a, const int64 b )
const uint64 operator () ( const uint64 a, const uint64 b )
Returns a pseudo-random value in interval: [a, b)
if a >= b
and [b, a)
otherwise.
module rand668.ty
Contains the definition of class Rand668
.
This a fast 64-bits Lagged Fibonacci Generator (LFib) with a quite long period (1.2×10201).
Lagged Fibonacci generators LFib( m, r, k, op) use the recurrence
xi = ( xi-r op xi-k ) mod m
where op is an operation that can be:
+ (addition),
– (substraction),
* (multiplication),
^ (bitwise exclusive-or).
With the + or – operation, such generators are in fact MRGs. They offer very large periods with the best known results in the evaluation of their randomness. It is recommended to use such pseudo-random numbers generators rather than LCG ones for serious simulation applications.
The implementation of this LFib 64-bits model is based on a Lagged Fibonacci generator (LFIB) that uses the recurrence
xi = ( xi-273 + xi-607 ) mod 264
and offers a period of about 2668 – i.e. 1.2×10201 – with low computation time due to the use of a 264 modulo but memory space consumption (607 long integers).
Notice that the TestUO1 article states that the operator should be ‘*’ while Mascagni & Srinivasan in their original article stated that the operator is ‘+’. We’ve implemented here the original operator: ‘+’.
See Rand78
, Rand116
and Rand1340
for long period LFib generators (resp. 278, 2116 and 21340 periods, i.e. resp. 3.0×1023, 8.3×1034 and 2.4×10403 periods) while same computation time and far higher precision (64-bits calculations) than MRGs, but memory consumption (resp. 17, 55 and 1279 integers).
This class and all its inheriting sub-classes are callable.
Example:
Rand668 rand = Rand668(); print( rand() ); // prints a uniform pseudo-random value within [0.0, 1.0) print( rand(a) ); // prints a uniform pseudo-random value within [0.0, a) print( rand(a,b) ); // prints a uniform pseudo-random value within [a , b)
For simulating the roll of a dice you should program:
Rand668 diceRoll = Rand668(); print( uint8(diceRoll(1, 7)) ); // prints a uniform roll within set {1, 2, 3, 4, 5, 6}
Rand668()
Rand668( const InternalState seed_state )
Constructors.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
none set_state()
none set_state( const InternalState seed_value )
Sets the value of a seed to initiate the next pseudo-random suite.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
InternalState get_state()
Returns the current internal state of the PRG. This state may be later used to set again the internal state of the PRG with this same value and generate then again the same pseudo-random suite of numbers.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
const float64 operator () ()
Returns a pseudo-random value in interval: [0.0, 1.0)
. This is the default signature used if the type of the expected returned value cannot be evaluated at translation time.
const int8 operator () ()
const int16 operator () ()
const int32 operator () ()
const int64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0x7f)
.
[0, 0x7fff)
.
[0, 0x7fff_ffff)
.
[0, 0x7fff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _int_
(i.e. of any signed integer type), the signature with const int64
is used.
const uint8 operator () ()
const uint16 operator () ()
const uint32 operator () ()
const uint64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0xff)
.
[0, 0xffff)
.
[0, 0xffff_ffff)
.
[0, 0xffff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _uint_
(i.e. of any signed integer type), the signature with const uint64
is used.
const float64 operator () ( const float64 b )
const int64 operator () ( const int64 b )
const uint64 operator () ( const uint64 b )
Returns a pseudo-random value in interval: [0, b)
if b > 0
and [b, 0)
otherwise.
const float64 operator () ( const float64 a, const float64 b )
const int64 operator () ( const int64 a, const int64 b )
const uint64 operator () ( const uint64 a, const uint64 b )
Returns a pseudo-random value in interval: [a, b)
if a >= b
and [b, a)
otherwise.
module rand1340.ty
Contains the definition of class Rand1340
.
This a fast 64-bits Lagged Fibonacci Generator (LFib) with a long period (2.4×10403).
Lagged Fibonacci generators LFib( m, r, k, op) use the recurrence
xi = ( xi-r op xi-k ) mod m
where op is an operation that can be:
+ (addition),
– (substraction),
* (multiplication),
^ (bitwise exclusive-or).
With the + or – operation, such generators are in fact MRGs. They offer very large periods with the best known results in the evaluation of their randomness. It is recommended to use such pseudo-random numbers generators rather than LCG ones for serious simulation applications.
The implementation of this LFib 64-bits model is based on a Lagged Fibonacci generator (LFIB) that uses the recurrence
xi = ( xi-861 + xi-1279 ) mod 264
and offers a period of about 21340 – i.e. 2.4×10403 – with low computation time due to the use of a 264 modulo but memory space consumption (607 long integers).
Notice that the TestUO1 article states that the operator should be ‘*’ while Mascagni & Srinivasan in their original article stated that the operator is ‘+’. We’ve implemented here the original operator: ‘+’.
See Rand78
, Rand116
and Rand668
for long period LFib generators (resp. 278, 2116 and 21340 periods, i.e. resp. 3.0×1023, 8.3×1034 and 1.2×10201 periods) while same computation time and far higher precision (64-bits calculations) than MRGs, but memory consumption (resp. 17, 55 and 607 integers).
This class and all its inheriting sub-classes are callable.
Example:
Rand1340 rand = Rand1340(); print( rand() ); // prints a uniform pseudo-random value within [0.0, 1.0) print( rand(a) ); // prints a uniform pseudo-random value within [0.0, a) print( rand(a,b) ); // prints a uniform pseudo-random value within [a , b)
For simulating the roll of a dice you should program:
Rand1340 diceRoll = Rand1340(); print( uint8(diceRoll(1, 7)) ); // prints a uniform roll within set {1, 2, 3, 4, 5, 6}
Rand1340()
Rand1340( const InternalState seed_state )
Constructors.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
none set_state()
none set_state( const InternalState seed_value )
Sets the value of a seed to initiate the next pseudo-random suite.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
InternalState get_state()
Returns the current internal state of the PRG. This state may be later used to set again the internal state of the PRG with this same value and generate then again the same pseudo-random suite of numbers.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
const float64 operator () ()
Returns a pseudo-random value in interval: [0.0, 1.0)
. This is the default signature used if the type of the expected returned value cannot be evaluated at translation time.
const int8 operator () ()
const int16 operator () ()
const int32 operator () ()
const int64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0x7f)
.
[0, 0x7fff)
.
[0, 0x7fff_ffff)
.
[0, 0x7fff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _int_
(i.e. of any signed integer type), the signature with const int64
is used.
const uint8 operator () ()
const uint16 operator () ()
const uint32 operator () ()
const uint64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0xff)
.
[0, 0xffff)
.
[0, 0xffff_ffff)
.
[0, 0xffff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _uint_
(i.e. of any signed integer type), the signature with const uint64
is used.
const float64 operator () ( const float64 b )
const int64 operator () ( const int64 b )
const uint64 operator () ( const uint64 b )
Returns a pseudo-random value in interval: [0, b)
if b > 0
and [b, 0)
otherwise.
const float64 operator () ( const float64 a, const float64 b )
const int64 operator () ( const int64 a, const int64 b )
const uint64 operator () ( const uint64 a, const uint64 b )
Returns a pseudo-random value in interval: [a, b)
if a >= b
and [b, a)
otherwise.
module rand1457.ty
Contains the definition of class Rand1457
.
This a fast 32-bits Multiple Recursive Generator (MRG) with a long period (3.98×10438).
Multiple Recursive Generators (MRGs) use the recurrence:
xi = [ A x sumj( xi-kj ) ] mod m
The implementation of this MRG 31-bits model is based on the DX-47-3 pseudo-random generator proposed by Deng and Lin. The DX-47-3 version uses the recurrence
xi = ( 226 + 219 ) x ( xi-1 + xi-24 + xi-47 ) mod (231 – 1)
and offers a period of about 21,457 – i.e. about 4.0×10438 – with low computation time.
See Rand287
for a shorter period MR-Generator (2287, i.e. 2.49×1086) with shorter computation time (232 modulus calculations) but 256 integers memory space consumption.
See Rand49507
for a far longer period (249,507, i.e. 1.2×1014,903 with low computation time too (31-bits modulus) but use of more memory space (1,597 integers).
This class and all its inheriting sub-classes are callable.
Example:
Rand1457 rand = Rand1457(); print( rand() ); // prints a uniform pseudo-random value within [0.0, 1.0) print( rand(a) ); // prints a uniform pseudo-random value within [0.0, a) print( rand(a,b) ); // prints a uniform pseudo-random value within [a , b)
For simulating the roll of a dice you should program:
Rand1457 diceRoll = Rand1457(); print( uint8(diceRoll(1, 7)) ); // prints a uniform roll within set {1, 2, 3, 4, 5, 6}
Rand1457()
Rand1457( const InternalState seed_state )
Constructors.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
none set_state()
none set_state( const InternalState seed_value )
Sets the value of a seed to initiate the next pseudo-random suite.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
InternalState get_state()
Returns the current internal state of the PRG. This state may be later used to set again the internal state of the PRG with this same value and generate then again the same pseudo-random suite of numbers.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
const float64 operator () ()
Returns a pseudo-random value in interval: [0.0, 1.0)
. This is the default signature used if the expected returned value cannot be evaluated at translation time.
const int8 operator () ()
const int16 operator () ()
const int32 operator () ()
const int64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0x7f)
.
[0, 0x7fff)
.
[0, 0x7fff_ffff)
.
[0, 0x7fff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _int_
(i.e. of any signed integer type), the signature with const int32
is used.
const uint8 operator () ()
const uint16 operator () ()
const uint32 operator () ()
const uint64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0xff)
.
[0, 0xffff)
.
[0, 0xffff_ffff)
.
[0, 0xffff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _uint_
, the signature with const uint32
is used.
const float64 operator () ( const float64 b )
const int64 operator () ( const int64 b )
const uint64 operator () ( const uint64 b )
Returns a pseudo-random value in interval: [0, b)
if b > 0
and [b, 0)
otherwise.
const float64 operator () ( const float64 a, const float64 b )
const int64 operator () ( const int64 a, const int64 b )
const uint64 operator () ( const uint64 a, const uint64 b )
Returns a pseudo-random value in interval: [a, b)
if a >= b
and [b, a)
otherwise.
module rand49507.ty
Contains the definition of class Rand49507
.
This a fast 32-bits Multiple Recursive Generator (MRG) with a very long period (nearly 1,2×1014,903).
Multiple Recursive Generators (MRGs) use the recurrence:
xi = [ A x sumj( xi-kj ) ] mod m
The implementation of this MRG 31-bits model is based on the ‘DX-1597-2-7’ MRG. It uses the recurrence
xi = ( -225 – 27 ) x ( xi-7 + xi-1,597 ) mod (231 – 1)
and offers a period of about 249,507 – i.e. about 1,2×1014,903 – with low computation time.
See Rand287
for a shorter period MR-Generator (2287, i.e. 2.49×1086) with shorter computation time (232 modulus calculations) but 256 integers memory space consumption.
See Rand1457
for a far longer period (21,457, i.e. 3.98×10438 with low computation time too (31-bits modulus) but use of more memory space (1,597 integers).
This class and all its inheriting sub-classes are callable.
Example:
Rand49507 rand = Rand49507(); print( rand() ); // prints a uniform pseudo-random value within [0.0, 1.0) print( rand(a) ); // prints a uniform pseudo-random value within [0.0, a) print( rand(a,b) ); // prints a uniform pseudo-random value within [a , b)
For simulating the roll of a dice you should program:
Rand49507 diceRoll = Rand49507(); print( uint8(diceRoll(1, 7)) ); // prints a uniform roll within set {1, 2, 3, 4, 5, 6}
Rand49507()
Rand49507( const InternalState seed_state )
Constructors.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
none set_state()
none set_state( const InternalState seed_value )
Sets the value of a seed to initiate the next pseudo-random suite.
seed_state
is the internal state of the PRG used as the seed for the next suite of pseudo-random numbers. There is a unique suite after each value for state. This allows the processing again of a same pseudo-random suite.
When seed_state
is not provided as an argument, the System time is used instead to evaluate a seed_value and then create the internal state of the PRG. Notice: current system time is shifted in-place to get more distinct pseudo-random suites from time to time.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
InternalState get_state()
Returns the current internal state of the PRG. This state may be later used to set again the internal state of the PRG with this same value and generate then again the same pseudo-random suite of numbers.
InternalState
is a class that is defined as a Base class for all LFib and MRG pseudo-random generators, in module Bases.base_rand_state.ty
. There is no need to know how this class is defined since its use is absolutely transparent to programmers. The only need is to know that this class exists and that internal states of most of PRGs in Typee are instances of this class.
seed_state
is a reference to an instance of this class.
const float64 operator () ()
Returns a pseudo-random value in interval: [0.0, 1.0)
. This is the default signature used if the expected returned value cannot be evaluated at translation time.
const int8 operator () ()
const int16 operator () ()
const int32 operator () ()
const int64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0x7f)
.
[0, 0x7fff)
.
[0, 0x7fff_ffff)
.
[0, 0x7fff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _int_
(i.e. of any signed integer type), the signature with const int32
is used.
const uint8 operator () ()
const uint16 operator () ()
const uint32 operator () ()
const uint64 operator () ()
Returns a pseudo-random value in interval, resp.:
[0, 0xff)
.
[0, 0xffff)
.
[0, 0xffff_ffff)
.
[0, 0xffff_ffff_ffff_ffff)
.
Notice: all these signatures are proposed to help getting the best randomness in returned suites with no a priori knowledge on the random implementation – which is dealt with internally by Typee.
If the expected returned type is known to be _uint_
, the signature with const uint32
is used.
const float64 operator () ( const float64 b )
const int64 operator () ( const int64 b )
const uint64 operator () ( const uint64 b )
Returns a pseudo-random value in interval: [0, b)
if b > 0
and [b, 0)
otherwise.
const float64 operator () ( const float64 a, const float64 b )
const int64 operator () ( const int64 a, const int64 b )
const uint64 operator () ( const uint64 a, const uint64 b )
Returns a pseudo-random value in interval: [a, b)
if a >= b
and [b, a)
otherwise.
Next section explains built-in library SQLite.