A Python implementation of various probability-based sampling algorithms, inspired by the R package sampling. This package offers a variety of sampling methods like Tillé's Method
, Poisson Sampling
, Systematic Sampling
, and more, designed for unequal probability sampling. The algorithms are implemented in a way that supports both theoretical understanding and real-world use cases.
You can install the package directly from PyPI:
pip install package-sampling
from package_sampling.sampling import up_brewer
import numpy as np
pik = np.array([0.1, 0.2, 0.3, 0.4])
# Draw a sample using Brewer's method
samples = up_brewer(pik)
print(samples)
Mohammadreza Razavian - smrrazavian@outlook.com Bardia Panahbehagh - Panahbehagh@khu.ac.ir
If you use this package in your work, please cite it as follows:
Razavian, M., & Panahbehagh, B. (2025). Package Sampling: A Python implementation of various probability-based sampling algorithms. https://github.com/smrrazavian/package-sampling.
@misc{razavian2025packagesampling,
author = {Razavian, Mohammadreza and Panahbehagh, Bardia},
title = {Package Sampling: A Python implementation of various probability-based sampling algorithms},
year = {2025},
url = {https://github.com/smrrazavian/package-sampling}
}
This package is inspired by the R package "Sampling" Thanks to all contributors and users
We welcome contributions to the package! If you have suggestions for new algorithms, improvements, or bug fixes, feel free to fork the repository and submit a pull request. Please ensure that your code adheres to the existing style and includes tests for any new functionality. Steps to Contribute:
- Fork the repository.
- Clone your fork to your local machine.
- Create a new branch for your changes.
- Make your changes and commit them with clear messages.
- Push your changes to your fork.
- Open a pull request describing your changes.