mt19937

package
v0.0.0-...-d740340 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package mt19937 implements 64-bit variant of Mersenne Twister pseudo-random number generator.

References:

M. Matsumoto and T. Nishimura, "Mersenne Twister: a 623-dimensionally equidistributed uniform pseudorandom number generator", ACM Transactions on Modeling and Computer Simulation 8. (Jan. 1998) 3--30.

http://www.math.sci.hiroshima-u.ac.jp/%7Em-mat/MT/emt64.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MT19937

type MT19937 struct {
	// contains filtered or unexported fields
}

MT19937 implements the 64-bit variant of the Mersenne Twister algorithm based on the Mersenne prime 2^19937-1 as its period.

func New

func New(seed uint64) *MT19937

New returns a new instance of the MT19937 PRNG Engine. If the seed provided is 0, the engine is initialized with current time

func (*MT19937) Float64

func (r *MT19937) Float64() float64

Float64 returns a pseudo-random number in [0.0, 1.0) as a float64. Float64 advances the internal state of the engine.

func (*MT19937) Float64OO

func (r *MT19937) Float64OO() float64

Float64OO returns a pseudo-random number in (0.0, 1.0) as a float64. Float6400 advances the internal state of the engine.

func (*MT19937) GetSeed

func (r *MT19937) GetSeed() uint64

GetSeed returns the seed used to initialize the engine

func (*MT19937) GetState

func (r *MT19937) GetState() []byte

GetState returns the internal state of the engine as []byte GetState can be used to save the state, e.g. to a file

func (*MT19937) Reset

func (r *MT19937) Reset()

Reset reverts the internal state of the engine to its default state, except the seed

func (*MT19937) Seed

func (r *MT19937) Seed(seed uint64)

Seed uses the provided value to initialize the engine If the seed provided is 0, the engine is initialized with current time

func (*MT19937) SetState

func (r *MT19937) SetState(b []byte)

SetState sets the internal state of the engine from a []byte SetState can be used to resume from a saved state

func (*MT19937) Uint64

func (r *MT19937) Uint64() uint64

Uint64 returns a pseudo-random 64-bit value in [0, 2^64) as a uint64. Uint64 advances the internal state of the engine.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL