Documentation
¶
Index ¶
- 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](r *Rand, t ...T) T
- func SampleFiltered[T any](r *Rand, slice []T, pred func(T) bool) int
- func SampleSeq[T any](r *Rand, it iter.Seq[T]) (sample T, ok bool)
- func SampleSlice[T any](r *Rand, slice []T) T
- func SampleWeighted[T any](r *Rand, slice []T, weight func(T) int) (T, bool)
- func SampleWeightedSeq[T any](r *Rand, it iter.Seq[T], weight func(T) int) (sample T, ok bool)
- func ShuffleSlice[Slice ~[]E, E any](s Slice, r *Rand)
- type PCG32
- type Rand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
func ShuffleSlice ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.