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 PermuteSlice[Slice ~[]E, E any](s Slice, seed uint32) iter.Seq2[int, E]
- 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) (T, bool)
- func SampleWeightedSeq[T any](it iter.Seq[T], weight func(T) int) (sample T, ok bool)
- func Seed(s int64)
- func Uint32() uint32
- type PCG32
- 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 PermuteSlice ¶ added in v0.11.8
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.
func SampleWeightedSeq ¶ added in v0.11.9
Types ¶
Click to show internal directories.
Click to hide internal directories.