randomness

Envision uses pseudo-randomness. If the script and the input data do not change, repeated runs produce identical results. Any data change resets the random sequences. The runtime manages seeds and preserves determinism even when execution is distributed.

Repeated calls to a random function within the same script return different values:

a = random.uniform(0, 1)
b = random.uniform(0, 1)

show summary "Random scalars" with
  a
  b

This outputs the following summary:

a b
0.6779699 0.5477362

Random scalar values are broadcast when assigned to a table column. Use into to generate per-row random values:

table T = extend.range(3)

T.X = random.uniform(0, 1)
T.Y = random.uniform(0 into T, 1)

show table "Random vectors" with
  T.X
  T.Y

This outputs the following table:

X Y
0.05126478 0.4794969
0.05126478 0.4816635
0.05126478 0.08181803

See also

User Contributed Notes
0 notes + add a note