Sequential Poisson sampling is a variation of Poisson sampling for drawing probability-proportional-to-size samples with a given number of units, and is commonly used for price-index surveys. This package is a Python implementation of the {sps} R package.
Install the stable release from PyPI
python -m pip install pyspsor get the development version from github
python -m pip install git+https://github.com/marberts/pysps.gitThe first step to draw a sample is to construct the inclusion probabilties for each unit in the population.
>>> import pysps
>>> pi = pysps.InclusionProb([1, 2, 3, 4], 3)
>>> pi
InclusionProb(array([0.33333333, 0.66666667, 1. , 1. ]), 3)Now these inclusion probabilities can be used to create a sample.
>>> samp = pysps.OrderSample(pi)
>>> samp.units
array([1, 2, 3])
>>> samp.weights
array([1.5, 1.0, 1.0])If you use this software, please cite it
@software{pysps,
author = {Martin, Steve},
doi = {10.5281/zenodo.15825865},
license = {MIT},
title = {{pysps: Sequential Poisson sampling}},
version = {0.1.1},
year = {2025}
}