Lemonergy · Studio block

Uniform random source

Produces reproducible uniform samples from a nonzero 32-bit seed and holds each sample until the next instant.

Implementation ID
native-uniform-random
Reviewed
2026-10-27

Behavior

x ^= x << 13; x ^= x >> 17; x ^= x << 5, using a 32-bit word. r = (x + 1)/(2³² + 1); y = lower + r(upper − lower).

Interface

Uniform random source interfaceInputs or arguments on the left, observed outputs on the right. Conserving terminals appear below the component. The tables give units and behavior.Uniform random sourceStudio blockout0
Original Lemonergy interface view. Lines identify ports; they are not a completed simulation circuit.
Ports and observed outputs
NameDirectionUnitMeaning
out0output1Signal; real scalar.

Parameters

Defaults are initial model values. Select values for your own model and operating conditions.

Configuration fields
ParameterUnitDefaultMeaning and limits
Sample period
sampleTimeS
s0.1Positive interval between sample instants. Values are held between samples.
Minimum 0
Seed (1–4294967295)
params[0]
11Configured value for Seed (1–4294967295).
Minimum
params[1]
10Configured value for Minimum.
Maximum
params[2]
11Configured value for Maximum.

Equations and rules

  • x ^= x << 13; x ^= x >> 17; x ^= x << 5, using a 32-bit word
  • r = (x + 1)/(2³² + 1); y = lower + r(upper − lower)

Worked example

Uniform random source — worked example

Use the configured source parameters. Signal at 0 s = 0.00006295042111003994.

Open Studio example after release →
Numerical checks for the bundled synthetic example
OutputTime (s)Expected valueUnitAbsolute tolerance
Signal
out0
06.295042111003994e-0511e-12

Explore the recorded outputs

Uniform random source recorded example

Uniform random source
Uniform random source against timeRecorded synthetic simulation values. Time in seconds; output in —.-0.0542485900.14263070.250.33951010.50.53638940.750.73326871—Time (s)
Uniform random source: 6.295042e-05 — at 0 s

11 actual recorded samples. Lines are visual guides between samples. Synthetic example, not measured cell data.

Download the recorded samples (JSON) · Open this Studio example after release

Use in a workflow

Uniform random source — worked example

Produces reproducible uniform samples from a nonzero 32-bit seed and holds each sample until the next instant.

  1. Uniform random source: x ^= x << 13; x ^= x >> 17; x ^= x << 5, using a 32-bit word. r = (x + 1)/(2³² + 1); y = lower + r(upper − lower).
    • Use the block reference for settings and connections.
    • Implementation tested locally; public release pending.
Open Studio example after release

Connected concepts

Limits and interpretation

  • Deterministic simulation noise, not a cryptographic generator. Samples lie strictly between configured bounds; seed zero is invalid.

Scientific and mathematical references

These sources explain the scientific and mathematical background. The behavior, interface and limits above define the Lemonergy implementation; a citation does not imply every model option in the source is implemented.

  1. Xorshift RNGs

    George Marsaglia · Journal of Statistical Software, 8(14) · 2003

    Technical reference · Xorshift random number generation; the exact 32-bit shifts and uniform scaling used here are specified by the Lemonergy contract.

Implementation sources

This reference follows the public interface and locally verified numerical checks for an upcoming release.

Contract: Lemonergy Studio public contract · Verification record: verification-2026-10-27

  • docs/glossary/native-block-verification.json

This implementation and its workflow uses (JSON) · Knowledge graph (JSON-LD)