PRNG (xoshiro128)

Overview

A pseudorandom number generator (PRNG) is an algorithm used to generate a sequence of numbers whose attributes approximate the attributes of sequences of random numbers. The sequence generated by PRNG is not truly random, because it is determined entirely by the initial value of a seed called PRNG. Here, a PRNG based on XOR/shift/rotate called xoshiro128 is implemented. Its algorithm comes from `PRNG`_.

.._`PRNG`: http://prng.di.unimi.it/

Implementation

There are 3 classes including XoShiRo128Plus, XoShiRo128PlusPlus, and XoShiRo128StarStar. Their implementation are similar. The only difference is in the private function rotl. In the pseudorandom number generation process, the seed needs to be initialized first by function init to determine the randomness of the output sequence. The function next can output random number with ii = 1.

Because the implementation is very common and very simple, it is not elaborated here. For more details, please see its source code and annotations.