/random

An implementation of Lemire's nearly divisionless random number generator

Primary LanguageGoApache License 2.0Apache-2.0

Build Status GoDoc

This repository contains a Go implementation of Lemire's "Fast Random Integer Generation in an Interval". See also Lemire's blog post and this blog post for more details.

The algorithm is Uint32n() in random.go, with tests and benchmarks in random_test.go.

The tests use the testify testing library, so first install it:

go get -u github.com/stretchr/testify

Then to run the tests, make sure that this repository is in $GOPATH/github.com/akalin/random, and do

go test -v github.com/akalin/random

and to run the benchmarks, do

go test -v github.com/akalin/random -bench .