Random Uniform

Shipping
array_random_uniform

i.i.d. uniform samples on [low, high) with a portable, reproducible RNG and seed output

Signature

Outputs

  • arrayArrayAn array of i.i.d. Uniform(low, high) samples; rank of the shape picks Vector / Matrix / Tensor.
  • seedScalarThe concrete seed actually used this run. When Seed = 0 (fresh entropy) this reports the drawn seed so you can pin it and reproduce the array.

Parameters

KeyTypeDefaultNotes
shapetext100Target shape as comma-separated dimensions (numpy-style): '5' → Vector, '3, 4' → Matrix, '2, 3, 4' → Tensor.
lowfloat0.0Inclusive lower bound.
highfloat1.0Exclusive upper bound (must be greater than Low).
seedint0Reproducibility seed. 0 = a fresh random array every run (read the actual seed off the `seed` output and type it here to lock that exact array). Any non-zero value reproduces bit-for-bit on every machine.
rng_algorithmenumchacha12one of: chacha12, chacha8, chacha20, pcg64, xoshiro256++, xoshiro256**
unittextOptional physical unit, applied only to a 1-D (Vector) result.

Description

Random Uniform is numpy.random.uniform: i.i.d. samples drawn from the half-open interval , filling an array of the requested Shape (rank picks Vector / Matrix / Tensor).

Randomness is portable and reproducible. Choosing an Algorithm picks a portable generator (ChaCha / PCG / xoshiro) that yields the same stream on any OS/CPU for a given seed — never the platform-dependent SmallRng. Seed draws fresh entropy each run and the node then reports the concrete seed it used on the second seed output; copy that value back into Seed to lock the exact array forever. A non-zero seed reproduces bit-for-bit everywhere. High Low or a non-finite bound is an error.

Mathematics

Examples

100 samples in [0, 1)

Defaults (Shape = 100, Low = 0, High = 1, Seed = 0) → a length-100 Vector of fresh uniform values, plus the drawn seed on the seed port.

Locking a matrix

Shape = 4, 4, Seed = 7 → the same 4×4 uniform Matrix on every machine and every run, because the seed is pinned and the RNG is portable.

Applications

  • Monte-Carlo sampling and randomized initialization for simulations.
  • Dithering, jitter, or randomized test-vector generation.
  • Bootstrap / permutation resampling with a reproducible, shareable seed.

Neat

The generator is deliberately portable (ChaCha/PCG/xoshiro), not Rust's SmallRng — a hard requirement so a shared project reproduces the identical array on any OS and CPU.

Seed = 0 doesn't mean 'seed with zero'; it means 'draw fresh entropy and tell me what you used' — the effective seed is emitted on a dedicated output port so the run stays reproducible after the fact.

Choosing a different Algorithm with the same seed produces a genuinely different stream (verified in tests), so the algorithm choice is itself part of the reproducibility contract.

Known issues

High must be strictly greater than Low (and both finite); otherwise it errors.

The unit is applied only to a rank-1 (Vector) result; Matrix/Tensor results drop it.

With Seed = 0 the array changes every run by design — it also emits a warning noting the array is non-deterministic until you pin the reported seed.

See also

arraytensorsourcerandomuniformmonte-carloreproducibleseedstateless