import "github.com/egdaemon/eg/runtime/x/wasi/egreservoir"
Package egreservoir provides reservoir sampling over sequences.
Sampler samples sequences of T using randomness derived from a seed.
type Sampler[T any] struct {
// contains filtered or unexported fields
}
func Seeded[T any](seed string) Sampler[T]
Seeded returns a Sampler whose randomness is derived from seed, the same seed over the same sequence yields the same sample.
func (t Sampler[T]) Sample(n int, seq iterx.Seq[T]) iterx.Seq[T]
Sample returns a Seq yielding a uniform random sample of up to n items from seq (reservoir sampling, Algorithm R). seq is consumed fully, memory is O(n), and the order of the yielded items is unspecified.