Trending

World technology news

→
Close-up photograph of dice illustrating random number generation.
crates.ioIn-depth report

algo-rng 0.1.0 packages three random number generators for simulation software

The package distributes SplitMix64, Xorshift128+ and PCG32 together.

·crates.io
Reading progress0%

Deterministic generators for repeatable simulations

algo-rng 0.1.0 packages three pseudorandom number generators for Rust applications: SplitMix64, Xorshift128+ and PCG32. A simulation that must reproduce input draws later needs to capture the generator, initialization value and order of consumption. A seed alone may not recover an earlier run after a change in the generator or in the order of calls. The crates.io record places the release at 09:39 Istanbul time. Docs.rs ran its own documentation build for the same version. That record identifies a successfully processed package and its build target. Runtime claims, especially those involving platform dependencies or external services, require their own observations. The checks below are examples an integrator could run.

The same seed across different algorithms

Giving two algorithms the same number does not imply the same sequence. Their state transitions and output sizes can differ. A small regression fixture can start each generator with a documented value and capture a few raw outputs. Its purpose is to verify the application’s selected generator over time. For reproduction, record which algorithm a stored seed belongs to and how the first output was read.

Call order is part of the experiment

An experiment might draw an arrival time and then a warehouse assignment. Adding a new draw between those steps changes what later calls receive even if the seed stays fixed. Separate streams or an explicit draw plan can make such changes easier to identify. Record the number of values consumed by each branch when comparing the experiment before and after an application change.

Sequence equality and distributions are separate questions

Reproducing a previous sequence is a regression check. Sampling many values to study a distribution is a separate exercise. Mapping a raw integer into a smaller set of outcomes can affect the resulting frequencies. Compare the mapping using fixed raw samples before comparing the generators themselves. A useful report states the number of draws and the conversion used.

Capture the reproducibility boundary

Record the application version, generator, seed and first few values in a fixture. A deterministic sequence is appropriate for a repeatable simulation. Security-sensitive key generation calls for a cryptographically suitable system source. The release and separate documentation build establish package identity. They do not provide a statistical or performance measurement for a particular workload.

A second run with two workers

Two workers can request values in different orders. A shared generator can produce the same global sequence while assigning different values to each worker. A stable allocation tied to task identity makes the second run easier to compare. Include worker count and task identifiers in the recorded inputs. Repeat the fixture if the build target changes. A hexadecimal representation can make the output width visible in reviews. Preserve the reviewed fixture with the simulation so a later run can be checked without relying on logs from the old environment.

Photo · Jack Elliott / Wikimedia Commons ↗ · CC BY 2.0

Sources and verification
Be the first reader ✎ Write a comment

Reader discussion

Discussion prompt

What would you change first for maintainability and testing in your own project?

No comments yet. Be the first to contribute.

Write a comment

Comments are real visitor contributions. Repeated, link-heavy or abusive submissions may be limited.