pcgr

package module
v0.0.0-...-4b34ab9 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 0 Imported by: 24

README

godoc: https://godoc.org/github.com/dgryski/go-pcgr

Documentation

Overview

Package pcgr implements a small PCG random number generator

http://www.pcg-random.org/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rand

type Rand struct {
	State uint64
	Inc   uint64 // must be odd
}

Rand is a PCG random number generator. It implements the rand.Source interface.

func New

func New(seed, state int64) Rand

New returns an pcgr stream

func (*Rand) Advance

func (r *Rand) Advance(delta int)

Advance skips forward 'delta' steps in the stream. Delta can be negative in which case the stream in rewound.

func (*Rand) Bound

func (r *Rand) Bound(bound uint32) uint32

Bound returns a uniform integer 0..bound-1

func (*Rand) Float32

func (r *Rand) Float32() float32

func (*Rand) Int63

func (r *Rand) Int63() int64

Int63 returns a random 63-bit integer

func (*Rand) Next

func (r *Rand) Next() uint32

Next returns a random uint32

func (*Rand) Seed

func (r *Rand) Seed(seed int64)

Seed states the internal state of the rng

func (*Rand) SeedWithState

func (r *Rand) SeedWithState(initstate, initseq int64)

SeedWithState sets the internal state and sequence number of the rng

Jump to

Keyboard shortcuts

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