Skip to main content

Module random

Module random 

Source
Expand description

Seeded pseudorandom numbers for turbulence, dispersions and Monte Carlo.

SeededRng is xoshiro256++, seeded from one u64 through SplitMix64, exactly as the authors’ reference code recommends:

The algorithm is part of the result: the same seed gives the same integer stream on every platform and in every release. Changing the generator, the seeding or the order of draws changes every seeded result, so it needs an ADR.

Normal deviates use the polar method of G. Marsaglia and T. A. Bray, “A convenient method for generating normal variables”, SIAM Review 6(3), 260–264 (1964): draw u, v uniform on (−1, 1) until 0 < s = u² + v² < 1, then u·√(−2 ln s / s) and v·√(−2 ln s / s) are two independent standard normal deviates. The second one is kept for the next call. The method needs only ln and sqrt, so normal deviates are bit-identical on one platform, and across platforms wherever their math libraries’ ln agree.

Structs§

SeededRng
A seeded xoshiro256++ generator with a standard normal sampler.