rand

package module
v0.0.0-...-129dfe0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package rand provides useful helper functions for math/rand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chance

func Chance(probability float64) bool

Chance evalutates a probability.

func Range

func Range(a, b float64) float64

Range returns a random number in the range [a, b).

func RangeInt

func RangeInt(a, b int) int

RangeInt returns a random integer in the range [a, b).

func Seed

func Seed(seed int64)

Seed uses the provided seed value to initialize the generator to a deterministic state.

Types

type Rand

type Rand struct {
	rand.Rand
}

Rand is a source of random numbers with some helper functions.

func New

func New(seed int64) *Rand

New returns a new Rand with the given seed.

func (*Rand) Chance

func (r *Rand) Chance(probability float64) bool

Chance evalutates a probability.

func (*Rand) Range

func (r *Rand) Range(a, b float64) float64

Range returns a random number in the range [a, b).

func (*Rand) RangeInt

func (r *Rand) RangeInt(a, b int) int

RangeInt returns a random integer in the range [a, b).

Jump to

Keyboard shortcuts

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