Documentation

9.2 Seed, label and stream derivation

nlmx creates a random stream from three pieces of identity:

master seed + SHA-256-derived label key + RNG derivation version

The label is hashed with SHA-256 and its first eight bytes become a u64. The seed is multiplied by a fixed mixing constant, then the label key and derivation version are added with wrapping integer arithmetic. The resulting odd state initializes SplitMix64.

Labels are scientific identifiers

Labels distinguish work units independently of scheduling. Examples in the code include draw indices, subject IDs, bootstrap replicates and scenario names. A subject simulation uses a label combining the caller's label and subject ID. Posterior quasi-random shifts include subject and dimension context.

Changing a label changes the stream even when the seed is unchanged. Labels should therefore be stable, unique and derived from durable identities—not worker number, processing order or a timestamp.

Hierarchical identity

Seed and label hierarchy

Conceptually, a trial-design simulation might label streams as:

scenario=rich | replicate=17 | subject=10042

The precise label format is command implementation, not a public invitation to predict values. Preserve command/version evidence because an upgraded derivation can intentionally change streams.

Independence claims

Labelled streams prevent accidental reuse caused by parallel scheduling. They do not mathematically prove statistical independence of all labels. SplitMix64 and SHA-256-based label separation provide a practical deterministic design; statistical quality and collision risk should be evaluated in the validation program.

Common mistakes

  • Using thread index as a stream label.
  • Assuming the same seed produces the same draws after labels change.
  • Calling differently labelled streams a formal proof of independence.

Checklist

  • Inventory every stream label and its work-unit identity.
  • Keep labels independent of traversal and worker assignment.
  • Record RNG derivation version with checkpoints.

Further reading

See generator algorithms, RNG versioning and thread determinism.