Pseudo-random numbers/Splitmix64: Difference between revisions

Content added Content deleted
(→‎{{header|Go}}: Removed preamble as all well now.)
m (Sigh. Spell algorithm name correctly in task header)
Line 1: Line 1:
{{draft task|PRNG}}
{{draft task|PRNG}}


Shiftmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes several fairly rigorous PRNG "fitness" tests that some more complex algorithms fail.
Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes several fairly rigorous PRNG "fitness" tests that some more complex algorithms fail.


Shiftmix64 is not recommended for demanding random number requirements, but is often used to calculate initial states for other more complex pseudo-random number generators.
Splitmix64 is not recommended for demanding random number requirements, but is often used to calculate initial states for other more complex pseudo-random number generators.


The "standard" shiftmix64 maintains one 64 bit state variable and returns 64 bits of random data with each call.
The "standard" splitmix64 maintains one 64 bit state variable and returns 64 bits of random data with each call.


Basic pseudocode algorithm:
Basic pseudocode algorithm:
Line 30: Line 30:
; Task:
; Task:


* Write a class or set of functions that generates pseudo-random numbers using shiftmix64.
* Write a class or set of functions that generates pseudo-random numbers using splitmix64.


* Show the first five integers generated using the seed 1234567.
* Show the first five integers generated using the seed 1234567.