Skip to content

marberts/pysps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sequential Poisson sampling

CI Build PyPI Python Versions Documentation DOI

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.

Installation

Install the stable release from PyPI

python -m pip install pysps

or get the development version from github

python -m pip install git+https://github.com/marberts/pysps.git

Usage

The 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])

Citation

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}
}

About

Sequential Poisson sampling in Python

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages