sps_iterator: Iteratively draw a sequential Poisson sample

View source: R/sps_iterator.R

sps_iteratorR Documentation

Iteratively draw a sequential Poisson sample

Description

Create a function that draws new units, one at a time, according to the sequential Poisson method without replacing previously sampled units.

Usage

sps_iterator(x, ..., n = 0L, prn = NULL)

Arguments

x

A positive and finite numeric vector of sizes for units in the population (e.g., revenue for drawing a sample of businesses).

...

Additional arguments to becomes_ta().

n

A positive integer giving the initial sample size for the iterator.

prn

A numeric vector of permanent random numbers for units in the population, distributed uniform between 0 and 1. The default does not use permanent random numbers, instead generating a random vector when the function is called.

Value

A function that returns the next unit in the sample. It take a single argument giving the sentinel value to indicate that there are no units left to sample (default NULL).

Examples

prn <- runif(5)
s <- sps_iterator(1:5, prn = prn)
s()
s()
s()

# Same as drawing the sample with 3 units.
sps(1:5, 3, prn = prn)

sps documentation built on Aug. 24, 2025, 9:08 a.m.