xoshiro

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2019 License: ISC Imports: 2 Imported by: 0

Documentation

Overview

Package xoshiro provides an implementation for a pseudo-random number generator (PRNG) using the xoshiro256** and xoshiro256+ algorithms.

Period: 2^256-1. State size: 256 bits.

Go implementation based on a C reference implementation by David Blackman and Sebastiano Vigna. For further information: http://xoshiro.di.unimi.it/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rng256P

type Rng256P [4]uint64

Rng256P encapsulates a xoshiro256+ PRNG.

xoshiro256+ 1.0 is Blackman & Vigna's best and fastest generator for floating-point numbers. The authors suggest to use its upper bits for floating-point generation, as it is slightly faster than xoshiro256**. It passes all tests the authors are aware of except for the lowest three 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.

The authors suggest to use a sign test to extract a random Boolean value, and right shifts to extract subsets of bits.

Note that the Go implementation of Rand.Float64 uses the upper bits as suggested.

func (*Rng256P) Int63

func (rng *Rng256P) Int63() int64

Int63 returns a non-negative pseudo-random 63-bit integer as an int64.

func (*Rng256P) Seed

func (rng *Rng256P) Seed(seed int64)

Seed uses the provided seed value to initialize the generator to a deterministic state.

func (*Rng256P) Uint64

func (rng *Rng256P) Uint64() uint64

Uint64 returns a pseudo-random 64-bit value as a uint64.

type Rng256SS

type Rng256SS [4]uint64

Rng256SS encapsulates a xoshiro256** PRNG.

xoshiro256** 1.0 is Black,an & Vigna's all-purpose, rock-solid generator. It has excellent (sub-ns) speed, a state (256 bits) that is large enough for any parallel application, and it passes all tests the authors are aware of.

For generating just floating-point numbers, xoshiro256+ is even faster.

func (*Rng256SS) Int63

func (rng *Rng256SS) Int63() int64

Int63 returns a non-negative pseudo-random 63-bit integer as an int64.

func (*Rng256SS) Seed

func (rng *Rng256SS) Seed(seed int64)

Seed uses the provided seed value to initialize the generator to a deterministic state.

func (*Rng256SS) Uint64

func (rng *Rng256SS) Uint64() uint64

Uint64 returns a pseudo-random 64-bit value as a uint64.

Jump to

Keyboard shortcuts

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