Documentation
¶
Overview ¶
Package rng provides a fast, per-instance random source. Unlike the stdlib global rand, every Generator owns its own *Rand, so concurrent goroutines never contend on a shared mutex — the classic faker bottleneck.
Index ¶
- type Rand
- func (r *Rand) Bool(p float64) bool
- func (r *Rand) Digits(n int) string
- func (r *Rand) Float64() float64
- func (r *Rand) Fork(i uint64) *Rand
- func (r *Rand) IntRange(min, max int) int
- func (r *Rand) Intn(n int) int
- func (r *Rand) NormFloat64() float64
- func (r *Rand) Pick(n int) int
- func (r *Rand) Uint64() uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rand ¶
type Rand struct {
// contains filtered or unexported fields
}
Rand is a lightweight, non-cryptographic PRNG. Not safe for concurrent use; give each goroutine its own via Fork or a pool.
func (*Rand) Fork ¶
Fork derives a new independent Rand for index i. It is a PURE function of this Rand's seed and i — it does not consume this Rand's stream — so record i is identical no matter the order or goroutine it is produced in.
func (*Rand) NormFloat64 ¶
NormFloat64 returns a standard-normal (mean 0, stddev 1) sample via Box-Muller. Used by the dist package for Normal/LogNormal.