This project is a minimalistic implementation of the Mersenne Twister pseudorandom number generator (PRNG) in Go. The Mersenne Twister algorithm, developed by Makoto Matsumoto and Takuji Nishimura, is a widely-used PRNG known for its long period and excellent statistical properties.
- Efficient and compact implementation of the Tiny Mersenne Twister algorithm in Go.
- Provides high-quality pseudorandom numbers with a period of 2^127-1.
- Supports both seeding with a single value and seeding with an array of values.
- Easy integration with existing Go projects.
- Standard library Go.
PRNGs (Pseudo Random Number Generators) come in different sorts. Similar to hash functions, some have the use of being "utility" focused, whereas others are cryptographically secure.
In particular, f
-
Start by installing Go and setting up your development environment.
-
Add the
mersennetwister
package to your project:go get github.com/aidenfoxivey/GoTinyMT
-
Import the package in your code:
import ( "fmt" "github.com/aidenfoxivey/GoTinyMT" )
-
Seed the Mersenne Twister generator with an initial value or an array of values:
seed := uint32(12345) mt := TinyMT32.Init(seed) // Or with an array of values seedArray := []uint32{123, 456, 789} mt := TinyMT32.InitArray(seedArray)
-
Generate pseudorandom numbers:
randNum := mt.Generate_uint32() // Generate a 32-bit unsigned random number
This project is licensed under the 3 clause BSD license.