Documentation ¶
Overview ¶
Package fastrand provides quickly generated pseudo-random numbers with no repeatability guarantees on the stream of values.
Index ¶
- func Fill(p []byte)
- func Float32() float32
- func Float64() float64
- func Int31() int32
- func Int31n(n int32) int32
- func Int63() int64
- func Int63n(n int64) int64
- func Jitter[T Real](v T, factor float64) T
- func NormFloat64() float64
- func Reader() io.Reader
- func Shuffle[E any](s []E)
- func Uint32() uint32
- func Uint64() uint64
- func Uint64n(n uint64) uint64
- func Uint64nUint32n(n uint32) uint32
- type Real
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Float32 ¶
func Float32() float32
Float32 returns a pseudo-random float32 in the half-open interval [0,n).
func Float64 ¶
func Float64() float64
Float64 returns a pseudo-random float64 in the half-open interval [0,n).
func Int31n ¶
Int31n returns a non-negative pseudo-random int32 in the half-open interval [0,n). It panics if n <= 0.
func Int63n ¶
Int63n returns a non-negative pseudo-random int64 in the half-open interval [0,n). It panics if n <= 0.
func Jitter ¶ added in v0.2.0
Jitter returns a pseudo-random value in the interval [v - factor*v, v + factor*v].
func NormFloat64 ¶
func NormFloat64() float64
NormFloat64 returns a normally distributed float64 in the range -math.MaxFloat64 through +math.MaxFloat64 inclusive, with standard normal distribution (mean = 0, stddev = 1). To produce a different normal distribution, callers can adjust the output using:
sample = NormFloat64() * desiredStdDev + desiredMean
func Reader ¶
Reader returns an io.Reader that fills the read buffer with pseudo-random bytes and never returns an error.
func Uint64nUint32n ¶
Uint32n returns a pseudo-random uint32 in the half-open interval [0,n).
Types ¶
type Real ¶ added in v0.2.1
type Real interface { constraints.Signed | constraints.Unsigned }
A Real is a real number.