random

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NextSeed int64 // is initialized to config.Cfg.Computation.Random_number_seed to avoid circular imports

Functions

func GetSeed

func GetSeed() int64

Get a random int64 from /dev/urandom to use as a seed

func Poisson

func Poisson(uniformRandom *rand.Rand, lambda float64) uint32

Algorithm taken from Wikipedia (https://en.wikipedia.org/wiki/Poisson_distribution#Generating_Poisson-distributed_random_variables). This differs from a naive implementation in avoiding rounding errors for lambda > 700

func RandFactory

func RandFactory() *rand.Rand

RandFactory returns a newly created random number generator with a new seed. Note: this is *not* thread safe, we assume you call this before starting the threads to give each its own RNG

func Round

func Round(uniformRandom *rand.Rand, num float64) int

Round randomly rounds an int either up or down, weighting the odds according to how far away from the integer it is. If the float is a perfect int, it always chooses that.

Types

This section is empty.

Jump to

Keyboard shortcuts

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