English

Randompack: Cross-Platform Reproducible Random Number Generation and Distribution Sampling

Applications 2026-05-11 v1 Mathematical Software

Abstract

A C library for random number generation, Randompack, is presented. The library implements several modern random number generators (engines), including xoshiro256, PCG64, Philox, ranlux++, and sfc64; 14 continuous distributions including uniform, normal, exponential, gamma, beta, and multivariate normal; raw bit streams, bounded integers, permutations, and sampling without replacement. The engine and the distribution layers are separated so any engine can be used with any distribution. Benchmarks show that Randompack is faster overall than competing libraries, with speedup factors ranging from about 1 to 15 depending on engine, distribution, interface, and platform. A distinguishing feature is reproducibility: with the same seeds Randompack gives compatible results across programming languages, computers, CPU architectures, and compilers. The library includes comprehensive support for parallel simulation. It is accompanied by a comprehensive test suite, benchmarking programs, and example programs. Interfaces to Fortran, Python, Julia, and R have been implemented; their benchmark results are included, although their design and implementation are otherwise outside the scope of the article. Unlike other available C libraries with comparable scope, Randompack is permissively licensed under the MIT license, and it is open source and publicly available through GitHub and conda-forge.

Keywords

Cite

@article{arxiv.2605.05099,
  title  = {Randompack: Cross-Platform Reproducible Random Number Generation and Distribution Sampling},
  author = {Kristján Jónasson},
  journal= {arXiv preprint arXiv:2605.05099},
  year   = {2026}
}

Comments

19 pages

R2 v1 2026-07-01T12:53:09.253Z