go-prng

module
v0.0.0-...-72f2e88 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2016 License: MIT

README

Go-PRNG

What

Go-PRNG is a collection of pseudo-random number generators. Each PRNG is given an easy-to-use interface, and some libraries implement math.Rand's Source interface.

Why

I was generating random strings and was accidentally using the same seed, causing me to generate the same strings. So, I went to use a quick and dirty XOR solution, and somehow ended up translating these PRNGs into Go.

How

xorshift
import (
	"fmt"
	
	prng "github.com/ericlagerg/go-prng/xorshift"
)

func main() {
	s := new(prng.Shift128Plus)
	s.Seed()
	fmt.Println(s.Next())
}
mersennes twister
import (
	"fmt"
	
	prng "github.com/ericlagerg/go-prng/mersenne_twister_64"
)

func main() {
	m := NewMersenne()
	m.Seed(787094841)
	fmt.Println(m.Int64())
}

Documentation

[godoc.org] docs

License

It depends on the algorithm.

[Apache 2.0] license.

Directories

Path Synopsis
/* ***************************************************************************** */ /* Copyright: Francois Panneton and Pierre L'Ecuyer, University of Montreal */ /* Makoto Matsumoto, Hiroshima University */ /* Notice: This code can be used freely for personal, academic, */ /* or non-commercial purposes.
/* ***************************************************************************** */ /* Copyright: Francois Panneton and Pierre L'Ecuyer, University of Montreal */ /* Makoto Matsumoto, Hiroshima University */ /* Notice: This code can be used freely for personal, academic, */ /* or non-commercial purposes.
Written in Go 2015 by Eric Lagergren (contact@ericlagergren.com) Written in C 2014 by Sebastiano Vigna (vigna@acm.org) and Kenji Rikitake (kenji.rikitake@acm.org).
Written in Go 2015 by Eric Lagergren (contact@ericlagergren.com) Written in C 2014 by Sebastiano Vigna (vigna@acm.org) and Kenji Rikitake (kenji.rikitake@acm.org).

Jump to

Keyboard shortcuts

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