Skip to content

Instantly share code, notes, and snippets.

@imneme
imneme / xoshiro.hpp
Created July 4, 2018 04:23
A C++ implementation of a family of Xoshiro generators
#ifndef XOSHIRO_HPP_INCLUDED
#define XOSHIRO_HPP_INCLUDED 1
/*
* A C++ implementation of a family of Xoshiro generators.
*
* See:
* https://arxiv.org/abs/1805.01407
* http://xoshiro.di.unimi.it/xoshiro256plus.c
* http://xoshiro.di.unimi.it/xoshiro256starstar.c
@imneme
imneme / splitmix.hpp
Created July 4, 2018 04:24
A C++ implementation of SplitMix
#ifndef SPLITMIX_HPP_INCLUDED
#define SPLITMIX_HPP_INCLUDED 1
/*
* A C++ implementation of SplitMix
* Original design by Guy L. Steele, Jr., Doug Lea and Christine H. Flood
* Described in _Fast splittable pseudorandom number generators_
* http://dx.doi.org/10.1145/2714064.2660195 and implemented in
* Java 8 as SplittableRandom
* Based on code from the original paper, with revisions based on changes
@imneme
imneme / arc4.hpp
Created July 5, 2018 13:04
A C++ port of the OpenBSD Arc4 random number generator
#ifndef ARC4_HPP_INCLUDED
#define ARC4_HPP_INCLUDED 1
/*
* A C++ port of the OpenBSD Arc4 random number generator
*
* The MIT License (MIT)
*
* Copyright (C) 1996 David Mazieres <dm@lcs.mit.edu> for the OpenBSD project
* C++ Port Copyright (c) 2014-18 Melissa E. O'Neill
@imneme
imneme / chacha.hpp
Last active April 18, 2024 06:56 — forked from orlp/chacha.h
C++11 ChaCha implementation.
#ifndef CHACHA_HPP_INCLUDED
#define CHACHA_HPP_INCLUDED 1
/*
* A C++ version of ChaCha PRNG (*modified* from Orson Peters original code)
*
* Changes Copyright (c) 2017-18 Melissa E. O'Neill, licence as below.
*
* Changes compared to original 2015 version:
* - Some formatting fixes
@imneme
imneme / seeding_bias.cpp
Last active June 24, 2019 01:06
Seeding Bias Test
/*
* Seeding Bias Test
*
* - Runs through all possible seeds and examines the output for
* bias. Doing so is only practical for 32-bit (or less) seeds
* and 32-bit (or less) output.
*
* Compilation note:
*
* - You need to define the following preprocessor symbols to compile this
@imneme
imneme / xoshiro256-similarity.c
Created December 4, 2020 22:37
This code shows self-similarity issues with Vigna's xoshiro256**. The original version of this code was written by Tyge Løvset.
/*
* Show self-similarity issues with Vigna's xoshiro256**
*
* Originally posted in a NumPy developers discussion by Tyge Løvset
* but simplified to only mix 32 outputs.
*
* Compile, and then test with PractRand by running
*
* ./xoshiro256-similarity \
* | ./RNG_test stdin64 -te 1 -tlmin 15 -tlmax 50 -tlmaxonly -multithreaded