rand2

package
v0.0.0-...-44111aa Latest Latest
Warning

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

Go to latest
Published: May 3, 2015 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

rand2 is a drop-in replacement for the "math/rand" package. It initializes the global random generator with a random seed (instead of 1), and provides additional functionality over the standard "math/rand" package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// See math/rand for documentation.
	New = rand.New

	// See math/rand for documentation.
	Seed = rand.Seed

	// See math/rand for documentation.
	Int63 = rand.Int63

	// See math/rand for documentation.
	Uint32 = rand.Uint32

	// See math/rand for documentation.
	Int31 = rand.Int31

	// See math/rand for documentation.
	Int = rand.Int

	// See math/rand for documentation.
	Int63n = rand.Int63n

	// See math/rand for documentation.
	Int31n = rand.Int31n

	// See math/rand for documentation.
	Intn = rand.Intn

	// See math/rand for documentation.
	Float64 = rand.Float64

	// See math/rand for documentation.
	Float32 = rand.Float32

	// See math/rand for documentation.
	Perm = rand.Perm

	// See math/rand for documentation.
	NormFloat64 = rand.NormFloat64

	// See math/rand for documentation.
	ExpFloat64 = rand.ExpFloat64

	// See math/rand for documentation.
	NewZipf = rand.NewZipf
)

Functions

func Dur

func Dur(max time.Duration) time.Duration

Dur returns a pseudo-random Duration in [0, max)

func Jitter

func Jitter(period time.Duration) time.Duration

Uniformly jitters the provided duration by +/- 50%.

func JitterFraction

func JitterFraction(period time.Duration, fraction float64) time.Duration

Uniformly jitters the provided duration by +/- the given fraction. NOTE: fraction must be in (0, 1].

func NewSource

func NewSource(seed int64) rand.Source

This returns a thread-safe random source.

func PickN

func PickN(population []interface{}, n int) (
	picked []interface{}, remaining []interface{}, err error)

Same as 'Sample' except it returns both the 'picked' sample set and the 'remaining' elements.

func Sample

func Sample(population []interface{}, k int) (res []interface{}, err error)

Samples 'k' elements from the given slice

func SampleInts

func SampleInts(n int, k int) (res []int, err error)

Samples 'k' unique ints from the range [0, n)

Types

This section is empty.

Jump to

Keyboard shortcuts

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