Documentation ¶
Overview ¶
Package mt19937 implements the 64-bit version of the Mersenne Twister (MT) pseudo-random number generator (PRNG) with a period of 2^19937-1, also known as mt19937_64, according to the reference implementation by Matsumoto and Nishimura at http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt64.html
MT is not cryptographically secure. Given a sufficiently long sequence of the generated values, one may predict additional values without knowing the seed. A secure hashing algorithm should be used with MT if a CSPRNG is required.
When possible, the MT generator should be seeded with a slice of bytes or uint64 values to address known "zero-excess" seed initialization issues where "shifted" sequences may be generated for seeds with only a few non-zero bits. For more information, see http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html
Index ¶
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 pseudo-random number generator that satisfies both math/rand.Source and math/rand.Source64.
func (*Source) Int63 ¶
Int63 returns the next pseudo-random integer on [0, 2^63-1) in the sequence. Both Uint64 and Int63 advance the sequence. Int63 satisfies math/rand.Source64.
func (*Source) Seed ¶
Seed initializes the source with the provided value. Note that SeedBytes or SeedValues should be preferred since Mersenne Twister suffers from a "zero-excess" initial state defect where seeds with many zero bits can result in similar/"shifted" sequences. The authors describe the issues: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html
func (*Source) SeedBytes ¶
SeedBytes seeds the mt19937 engine with up to 2496 bytes from a slice. Only the first 2496 bytes of the slice are used. Additional elements are unused.