Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChooseOne ¶
ChooseOne randomly picks an index between 0 and len(weights)-1 inclusively. Each index has the probability of getting selected based on its weight.
func ChooseSome ¶
ChooseSome randomly picks non-duplicate "cnt" indexes between 0 and len(weights)-1 inclusively. The function calls ChooseOne to get an index based on the given weights. When an index is chosen, it gets removed from the pool. The process gets repeated until "cnt" indexes are chosen.
Types ¶
type Rng ¶
type Rng struct {
// contains filtered or unexported fields
}
Rng implements a simple determinisic random number generator. Starting from an initial entropy, nonce, and personalizationString, it utilizes HMAC_DRBG construct as per NIST Special Publication 800-90A to produce a stream of random uint64 integers.
func NewRng ¶
NewRng creates a new psudo-random generator, using the given seeds as the initial random source.
func (*Rng) NextUint64 ¶
NextUint64 returns the next 64-bit unsigned random integer produced by this generator.