rng

package
v3.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixedInt

func FixedInt(n int, hint string) int

FixedInt returns an integer in [0, n) that stays the same if the same hint is provided.

This fixed integer may change in different mieru versions.

This function uses an internal hint cache to accelerate look up.

func FixedIntPerHost

func FixedIntPerHost(n int) int

FixedIntPerHost returns an integer in [0, n) that stays the same on the same host.

func FlipBits

func FlipBits(bs []byte, src byte, ratio float64) []byte

FlipBits modifies the input byte slice by changing some bits from 0 -> 1 or 1 -> 0.

The `src` must be either 0 or 1. When it is 0, some 0 bits will be changed to 1 bits. When it is 1, some 1 bits will be changed to 0 bits.

The `ratio` specifies the desired ratio of `src` bits in the byte slice after flip. The value must be within [0.0, 1.0]. When the input slice already has a smaller ratio, no flip is performed.

func Int63n

func Int63n(n int64) int64

Intn returns a random int64 from [0, n) with scale down distribution.

func IntRange

func IntRange(m, n int) int

IntRange returns a random int from [m, n) with scale down distribution.

func IntRange64

func IntRange64(m, n int64) int64

IntRange64 returns a random int64 from [m, n) with scale down distribution.

func Intn

func Intn(n int) int

Intn returns a random int from [0, n) with scale down distribution.

func RandTime

func RandTime(begin, end time.Time) time.Time

RandTime returns a random time from [begin, end) with scale down distribution.

Types

This section is empty.

Jump to

Keyboard shortcuts

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