nnnnnnnn
(Nate Cook)
February 14, 2020, 5:05pm
7
The Swift project has a couple RNG implementations to support various tests. The SplitMix RNG is good and a lot faster than the system RNG — if you initialize it with a seed from the system RNG, you should get what you're looking for:
@available(*, deprecated, renamed: "LFSR.next()")
public func Random() -> Int64 {
return lfsrRandomGenerator.next()
}
// This is a fixed-increment version of Java 8's SplittableRandom generator.
// It is a very fast generator passing BigCrush, with 64 bits of state.
// See http://dx.doi.org/10.1145/2714064.2660195 and
// http://docs.oracle.com/javase/8/docs/api/java/util/SplittableRandom.html
//
// Derived from public domain C implementation by Sebastiano Vigna
// See http://xoshiro.di.unimi.it/splitmix64.c
public struct SplitMix64: RandomNumberGenerator {
private var state: UInt64
public init(seed: UInt64) {
self.state = seed
}
public mutating func next() -> UInt64 {
This file has been truncated. show original
1 Like