Documentation
¶
Index ¶
- func AdjectiveNoun() string
- func Float32() float32
- func Int31n(n int32) int32
- func Intn(n int) int
- func PermutationElement(i int, n int, p uint32) int
- func Sample[T any](t ...T) T
- func SampleFiltered[T any](slice []T, pred func(T) bool) int
- func SampleSlice[T any](slice []T) T
- func SampleWeighted[T any](slice []T, weight func(T) int) int
- func Seed(s int64)
- type Rand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdjectiveNoun ¶
func AdjectiveNoun() string
func PermutationElement ¶
PermutationElement returns the ith element of a random permutation of the set of integers [0...,n-1]. i/n, p is hash, via Andrew Kensler
func SampleFiltered ¶
SampleFiltered uniformly randomly samples a slice, returning the index of the sampled item, using provided predicate function to filter the items that may be sampled. An index of -1 is returned if the slice is empty or the predicate returns false for all items.
func SampleSlice ¶
func SampleSlice[T any](slice []T) T
SampleSlice uniformly randomly samples an element of a non-empty slice.
func SampleWeighted ¶
SampleWeighted randomly samples an element from the given slice with the probability of choosing each element proportional to the value returned by the provided callback.
Types ¶
Click to show internal directories.
Click to hide internal directories.