SBRandom#

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

rand = SBRandom()
# Generates a random number on [0,1]-real-interval
rand.randDouble1()

Note that the default constructor of SBRandom has a fixed seed. This is useful when debugging code, since it allows for reproducible results. For a “production run”, though, a SBRandom object should be seeded with a random number, for example using SAMSON.getTime()

rand = SBRandom(SAMSON.getTime() % 2147483647)
# create a random UUID
rand.randUUID()

See also

SAMSON SDK: SBDTypeRandom

class samson.SBRandom(*args, **kwargs)#

Bases: pybind11_object

This class implements a random number generator

Overloaded function.

  1. __init__(self: samson.SBRandom) -> None

  2. __init__(self: samson.SBRandom, arg0: int) -> None

randDouble1(self: samson.SBRandom) float#

Generates a random number on [0,1]-real-interval

randDouble2(self: samson.SBRandom) float#

Generates a random number on [0,1)-real-interval

randDouble3(self: samson.SBRandom) float#

Generates a random number on (0,1)-real-interval

randLong(self: samson.SBRandom) int#

Generates a random number on [0,0x7fffffff]-interval

randRes53(self: samson.SBRandom) float#

Generates a random number on [0,1) with 53-bit resolution

randUUID(self: samson.SBRandom) samson.SBUUID#

Generates a random 32-character hexadecimal chain with the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

randUnitSphere3(self: samson.SBRandom) samson.SBPhysicalVector3#

Generates a point on the unit 3D sphere with uniform spherical distribution

randUnsignedLong(self: samson.SBRandom) int#

Generates a random number on [0,0xffffffff]-interval

seed(self: samson.SBRandom, iseed: int) None#

Reseed the random generator