rndm
A tiny, dependency-free random number utility built on SplitMix64.
It provides:
- Uniform integers without modulo bias (rejection sampling)
- Fixed-precision uniform floats within a range
- Optional independent streams via
stream_id - Fast
randbits(k)for bit generation
Not for cryptography. SplitMix64 is great for simulations, sampling, games, and testing—but not for security.
Install
From PyPI
pip install rndm
From source (GitHub)
pip install .
For development:
pip install -e ".[dev]"
Quick start
import rndm
# (optional) reseed; if you don't, it seeds automatically on first use
rndm.reseed()
# Uniform int in [0, 10] (inclusive by default)
x = rndm.time_based_random(0, 10)
print(x)
# Uniform int in [50, 1000), exclusive upper bound
y = rndm.time_based_random(50, 1000, inclusive=False)
print(y)
# Uniform float in [-1.0, 1.0] with precision inferred from inputs (1 decimal here)
z = rndm.time_based_random(-1.0, 1.0)
print(z)
# Force precision (e.g., 3 decimals)
w = rndm.time_based_random("0.000", "0.999", precision=3)
print(w)
# Independent streams
rndm.set_stream_id(123)
a1 = rndm.time_based_random(0, 10)
rndm.set_stream_id(456)
a2 = rndm.time_based_random(0, 10)
API
-
reseed(seed: int | None = None, stream_id: int | None = None) -> int
Reseeds the generator. IfseedisNone, uses a mixed time-based seed. Returns the internal 64-bit state. -
set_stream_id(stream_id: int) -> None
Switches to a different independent stream (reseeds automatically). -
randbits(k: int) -> int
Returns an integer withkrandom bits. -
time_based_random(min_value=0, max_value=1, inclusive=True, precision=None)- If both bounds are
int, returns anint - Otherwise returns a
floatrounded toprecisiondecimals (or inferred from inputs). - Uses rejection sampling (no
%modulo reduction), so integer ranges are unbiased.
- If both bounds are
Benchmarks
The repository includes example benchmark outputs under https://github.com/bio-informatician/rndm/tree/main/benchmarks/:
- Distribution plots:
https://github.com/bio-informatician/rndm/tree/main/benchmarks/plots/ - Bin counts (CSV):
https://github.com/bio-informatician/rndm/tree/main/benchmarks/counts/ - Summary table: summary
Example figures:
Development
Run tests:
pytest
Build a wheel + sdist:
python -m pip install --upgrade build
python -m build
License
MIT — see LICENSE.
Metadata
Release files for rndm 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rndm-0.1.3.tar.gz | 5.8 kB | Without provenance | Details for rndm-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rndm-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for rndm-0.1.3-py3-none-any.whl |
Total release size: 12.0 kB
Release files / rndm-0.1.3.tar.gz
| Download URL | rndm-0.1.3.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4150cec7f51791334e4e1a54b994fc6aed7730b8cdfc1287510e6ee96f748e72
|
|
BLAKE2b-256 checksum How to use checksums |
d5e9e4b013bd09231220dc61b3bc05ccaeac0c10da078d106a099f51d5cb0abe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.10
|
Release files / rndm-0.1.3-py3-none-any.whl
| Download URL | rndm-0.1.3-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
54518047a0c28b076479c9332c63ed832cf8c4b7fa30bca42d6f08f134b271a6
|
|
BLAKE2b-256 checksum How to use checksums |
856dffe4485394d23777c444613cd44c0fe44bf309836605c27c8b00142d2503
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.10
|
Security for rndm 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.