Documentation
¶
Overview ¶
Package simple implements an unweighted reservoir sampling algorithm.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Simple ¶
type Simple[T any] struct { // contains filtered or unexported fields }
Simple implements unweighted reservoir sampling using Algorithm R from "Random sampling with a reservoir" by Jeffrey Vitter (1985) https://en.wikipedia.org/wiki/Reservoir_sampling#Algorithm_R
func New ¶
New returns a simple reservoir sampler with given capacity (i.e., reservoir size) and random number generator.
func (*Simple[T]) Add ¶
func (s *Simple[T]) Add(item T)
Add considers a new observation for the sample. Items have unit weight.
Click to show internal directories.
Click to hide internal directories.