RandomLCG

Deterministic linear congruential pseudo-random generator with one mutable seed and three derived output views.


State evolution


State model


Generator step


Output mappings


Determinism and replay


Examples

Initial sequence

"RandomLCG" use
"control" use

{} () {} [
  r: RandomLCG;
  @r.nextSeed printStack _:;
  @r.nextSeed printStack _:;
  @r.getr32 printStack _:;
] "main" exportFunction

Expected Output During Compilation

1n32
134775814n32
0.86105r32

State progression checks

"RandomLCG" use
"control" use

{} () {} [
  r: RandomLCG;
  @r.nextSeed 1n32 same printStack _:;
  @r.nextSeed 134775814n32 same printStack _:;
  @r.getr32 0.86105r32 same printStack _:;
] "main" exportFunction

Expected Output During Compilation

TRUE
TRUE
TRUE

Runtime sequence

"RandomLCG" use
"String" use
"control" use

{} Int32 {} [
  r: RandomLCG;
  ("seed1=" @r.nextSeed LF
   "seed2=" @r.nextSeed LF
   "r32=" @r.getr32 LF) printList
  0
] "main" exportFunction

Expected Output

seed1=1
seed2=134775814
r32=0.86105

See also