nprand

package
v0.0.0-...-3511abf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	Key [stateLen]uint32 `json:"key"`
	Pos int              `json:"pos"`
}

State is the state of the random number generator.

func New

func New(seed uint32) *State

New creates a new seeded RNG state.

func (*State) Bits32

func (state *State) Bits32() uint32

Bits32 generates 32 bits of randomness.

func (*State) Bits64

func (state *State) Bits64() uint64

Bits64 generates 64 bits of randomness.

func (*State) Int64

func (state *State) Int64(low, high int64) int64

Int64 generates a random Int64 in [low, high). It panics if high <= low.

func (*State) Int64n

func (state *State) Int64n(n int64) int64

Int64n generates a random Int64 in [0, n). It panics if n <= 0.

func (*State) Intn

func (state *State) Intn(n int) int

Intn generates a random Int in [0, n). It panics if n <= 0.

func (*State) Read

func (state *State) Read(p []byte) (int, error)

Read implements the Reader interface, yielding a random stream of bytes.

func (*State) Seed

func (state *State) Seed(seed uint32)

Seed initializes the RNG state.

func (*State) Uniform

func (state *State) Uniform(low, high float64) float64

Uniform generates a random float64 uniformly distributed in [low, high). It panics if high <= low.

func (*State) UnitInterval

func (state *State) UnitInterval() float64

UnitInterval generates a random float64 in [0,1).

Jump to

Keyboard shortcuts

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