Class SBDTypeRandom#
This class implements a random number generator. More...
#include <SBDTypeRandom.hpp>
Public Functions#
| Type | Name |
|---|---|
| SBDTypeRandom () Constructs a random generator with fixed seed. |
|
| SBDTypeRandom (unsigned long s) Constructs a random generator with custom seed. |
|
| double | randDouble1 () Generates a random number on [0,1]-real-interval. |
| double | randDouble2 () Generates a random number on [0,1)-real-interval. |
| double | randDouble3 () Generates a random number on (0,1)-real-interval. |
| long | randLong () Generates a random number on [0,0x7fffffff]-interval. |
| double | randRes53 () Generates a random number on [0,1) with 53-bit resolution. |
| SBCContainerUUID | randUUID () Generates a random 32-character hexadecimal chain with the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. |
| SBVector3 | randUnitSphere3 () Generates a point on the unit 3D sphere with uniform spherical distribution. |
| unsigned long | randUnsignedLong () Generates a random number on [0,0xffffffff]-interval. |
| void | seed (unsigned long s) Reseed the random generator. |
| ~SBDTypeRandom () Destructs the random generator. |
Protected Attributes#
| Type | Name |
|---|---|
| SBDTypeRandomData * | dataPointer A pointer to the private data. |
Detailed Description#
The class SBDTypeRandom generator implements the Mersenne Twister generator from the paper: M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-dimensionally equidistributed uniform pseudorandom number generator", ACM Trans. on Modeling and Computer Simulation Vol. 8, No. 1, January pp.3-30 (1998).
Note that the default constructor of SBDTypeRandom, SBDTypeRandom::SBDTypeRandom(), has a fixed seed. This is useful when debugging code, since it allows for reproducible results. For a "production run", though, a SBDTypeRandom object should be seeded with a random number, for example using SAMSON::getTime():
Short name: SBRandom
See also: SBUUID
Public Functions Documentation#
function SBDTypeRandom [1/2]#
Constructs a random generator with fixed seed.
Constructs a random generator with a fixed seed.
The generator is initialized with a predetermined seed, providing reproducible random sequences.
function SBDTypeRandom [2/2]#
Constructs a random generator with custom seed.
Constructs a random generator with a custom seed.
Parameters:
sThe seed value used to initialize the random number generator.
function randDouble1#
Generates a random number on [0,1]-real-interval.
Generates a random double in the inclusive interval [0, 1].
Returns:
A random double value between 0 and 1, inclusive.
function randDouble2#
Generates a random number on [0,1)-real-interval.
Generates a random double in the half-open interval [0, 1).
Returns:
A random double value greater than or equal to 0 and less than 1.
function randDouble3#
Generates a random number on (0,1)-real-interval.
Generates a random double in the open interval (0, 1).
Returns:
A random double value strictly greater than 0 and less than 1.
function randLong#
Generates a random number on [0,0x7fffffff]-interval.
Generates a random signed integer in the range [0, 0x7fffffff].
Returns:
A random long value.
function randRes53#
Generates a random number on [0,1) with 53-bit resolution.
Generates a random double in the interval [0, 1) with 53-bit resolution.
Returns:
A random double value with high precision in the range [0, 1).
function randUUID#
Generates a random 32-character hexadecimal chain with the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
Generates a random universally unique identifier (UUID).
Returns:
A UUID consisting of 32 hexadecimal characters formatted as XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
function randUnitSphere3#
Generates a point on the unit 3D sphere with uniform spherical distribution.
Generates a random point on the unit sphere with a uniform spherical distribution.
Returns:
A 3D vector representing a point on the surface of the unit sphere.
function randUnsignedLong#
Generates a random number on [0,0xffffffff]-interval.
Generates a random unsigned 32-bit integer in the range [0, 0xffffffff].
Returns:
A random unsigned long value.
function seed#
Reseed the random generator.
Reseeds the random generator.
Parameters:
sThe new seed value.
function ~SBDTypeRandom#
Destructs the random generator.
Destroys the random generator and releases any allocated resources.
Protected Attributes Documentation#
variable dataPointer#
A pointer to the private data.