Metadata-Version: 2.4
Name: pysps
Version: 0.1.1
Summary: Sequential Poisson sampling for Python.
Author-email: Steve Martin <marberts@protonmail.com>
License-Expression: MIT
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=2.2.2
Dynamic: license-file

# Sequential Poisson sampling

[![CI Build](https://github.com/marberts/pysps/actions/workflows/ci-tests.yml/badge.svg)](https://github.com/marberts/pysps/actions/workflows/ci-tests.yml)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15825865.svg)](https://doi.org/10.5281/zenodo.15825865)

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}](https://cran.r-project.org/package=sps) R package.

## Installation

Install the stable release from PyPI

```bash
python -m pip install pysps
```

or get the development version from github

```bash
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.

```python
>>> 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.

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