Algorithms, Sampling.
Implementation @dataclass class Reservoir: k: int seed: t.Optional[int] = None def __post_init__(self): # for reproducibility if self.seed is not None: assert self.seed > 0 # number of items consumed so far self.i = 0 self.sample: t.List[A] = [] def add(self, item: A) -> None: self.i += 1 if