Documentation
¶
Overview ¶
Package xoroshiro128p implements xoroshiro128+ 1.0, our best and fastest small-state generator for floating-point numbers. We suggest to use its upper bits for floating-point generation, as it is slightly faster than xoroshiro128++/xoroshiro128**. It passes all tests we are aware of except for the four lower bits, which might fail linearity tests (and just those), so if low linear complexity is not considered an issue (as it is usually the case) it can be used to generate 64-bit outputs, too; moreover, this generator has a very mild Hamming-weight dependency making our test (http://prng.di.unimi.it/hwd.php) fail after 5 TB of output; we believe this slight bias cannot affect any application. If you are concerned, use xoroshiro128++, xoroshiro128** or xoshiro256+.
We suggest to use a sign test to extract a random Boolean value, and right shifts to extract subsets of bits.
The state must be seeded so that it is not everywhere zero. If you have a 64-bit seed, we suggest to seed a splitmix64 generator and use its output to fill s.
NOTE: the parameters (a=24, b=16, b=37) of this version give slightly better results in our test than the 2016 version (a=55, b=14, c=36).
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source is a random source using xoroshiro128+ algorithm.
Go port of http://prng.di.unimi.it/xoroshiro128plus.c
Example ¶
package main
import (
"fmt"
"math/rand"
"github.com/shogo82148/randsrc/xoroshiro128p"
)
func main() {
src := xoroshiro128p.New([2]uint64{1})
r := rand.New(src)
for i := 0; i < 10; i++ {
fmt.Println(r.Int63())
}
}
Output: 0 68727898112 1162069580936380928 36099245263065744 1306769709744035040 2568221860186161298 3046776487690310554 8213190904191315488 3214698032120034443 292334754365524544