PureRNGs.jl
PureRNGs provides counter-based random numbers with explicit state. Generate arrays on a CPU or GPU, or draw inside your own kernels.
using PureRNGs, Random
rng = Philox4x32(123456)
values, next_rng = rand_next(rng, Float32, 4)
@assert values == rand_at(rng, Float32, 1:4)
values4-element Vector{Float32}:
0.053103805
0.2822104
0.3456427
0.5453631The draw leaves rng unchanged. Use next_rng to continue the stream.
Start here
Read Getting started for the basic workflow. Then choose a task:
- Arrays and performance: fill buffers and control CPU threading.
- Sampling: draw from integer ranges or weighted populations.
- Parallel jobs: assign stable streams to independent work.
- GPU kernels: generate numbers where the computation runs.
- Particle filter: combine propagation, weighting, and resampling, then fuse a small filter into one kernel.
Understand the contract
Generators and streams explains keys, positions, and splitting. Reproducibility separates stream guarantees from floating-point differences. Devices lists backend support and placement rules.
Random interoperability, Distributions, and Differentiation and compilation cover optional integrations. The API reference lists exported functions. See Acknowledgements for prior art and full references for the algorithms and validation tools.
PureRNGs is not a cryptographic random-number generator.