mtrand

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: MIT Imports: 0 Imported by: 0

README

mtrand

Introdution

mtrand based on Mersenne Twister algorithm. The Mersenne Twister is a strong pseudo-random number generator. Strong PRNG has a long period (how many values it generates before repeating itself) and a statistically uniform distribution of values (bits 0 and 1 are equally likely to appear regardless of previous values). A version of the Mersenne Twister available in many programming languages, MT19937, has an impressive period of 2^19937-1.

Installation

go get "github.com/wmentor/mtrand"

Usage

package main

import (

  "fmt"
  "time"

  "github.com/wmentor/mtrand"
)

func main() {

  gen := mtrand.New()
  gen.Seed(time.Now().UnixNano())


  for i := 0 ; i < 1000 ; i++ {

    // get int64 value
    // or you can call gen.Uint64 to get uint64
    fmt.Println(gen.Int63())
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rand

type Rand struct {
	// contains filtered or unexported fields
}

func New

func New() *Rand

func (*Rand) Int63

func (mt *Rand) Int63() int64

func (*Rand) Read

func (mt *Rand) Read(p []byte) (n int, err error)

func (*Rand) Seed

func (mt *Rand) Seed(seed int64)

func (*Rand) SeedFromSlice

func (mt *Rand) SeedFromSlice(key []uint64)

func (*Rand) Uint64

func (mt *Rand) Uint64() uint64

Jump to

Keyboard shortcuts

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