alea

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Random numbers generator

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GaussRand

func GaussRand() float64

Same as Generator.GaussRand () with the default generator.

func IntRand

func IntRand(min, max int64) int64

Same as Generator.IntRand () with the default generator.

func Random

func Random() float64

Same as Generator.Random () with the default generator.

func Randomize

func Randomize(seed int64)

Same as Generator.Randomize () with the default generator.

func UintRand

func UintRand(min, max uint64) uint64

Same as Generator.UintRand () with the default generator.

Types

type Generator

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

func New

func New() *Generator

Initializes the generator with a random seed.

func (*Generator) GaussRand

func (g *Generator) GaussRand() float64

Generates a new pseudo-random real number x with gaussian (normal) deviates. Probability distribution p(x) = 1 / sqrt(2 * pi) * exp(-x^2 / 2). Box-Muller method.

func (*Generator) IntRand

func (g *Generator) IntRand(min, max int64) int64

Generates a new integer number between min (included) and max (excluded)

func (*Generator) Random

func (g *Generator) Random() float64

Generates a new pseudo-random real number x such that (0 <= x < 1), with uniforme deviates. (Period > 2 × 10^18). Ref.: Generator ran2, W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery, Numerical Recipes, The Art of Scientific Computing, second edition, 1997.

func (*Generator) Randomize

func (g *Generator) Randomize(seed int64)

Initializes the pseudo-random number generator with seed.

func (*Generator) UintRand

func (g *Generator) UintRand(min, max uint64) uint64

Generates a new unsigned integer number between min (included) and max (excluded)

Jump to

Keyboard shortcuts

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