binsmooth
Python implementation of "Better Estimates from Binned Income Data"
Better Estimates from Binned Income Data: Interpolated CDFs and Mean-Matching
Paul T. von Hippel, David J. Hunter, McKalie Drown
Sociological Science
Volume 4, Number 26, Pages 641-655
2017
Originally implemented in the R package binsmooth.
Usage
from binsmooth import BinSmooth
bin_edges = np.array([0, 18200, 37000, 87000, 180000])
counts = np.array([0, 7527, 13797, 75481, 50646, 803])
mean_estimate = 95000
bs = BinSmooth()
bs.fit(bin_edges, counts, m=mean_estimate)
# Print median estimate
print(bs.inv_cdf(0.5))
Installation
Install via pip
pip install binsmooth
pypi page https://pypi.org/project/binsmooth/
Improvements
Better tail estimate by bounded optimisation rather than the adhoc search method found in the R implementation.
More precise inverse CDF by dynamically sampling the CDF. This is done by sampling proportional to the steepness of the CDF i.e. sampling more in areas where the CDF is steeper.
Warnings
Results may not exactly match R binsmooth because of a different approach
to estimating the tail (upper bound).
Furthermore the fit method uses spline_type="PCHIP" by default, which is
scipy's PchipInterpolator [1]. While the R implementation uses the spline
from [2], which can be mimicked by setting spline_type="HYMAN".
References
[1]: Fritsch, F. N. and Carlson, R. E. (1980). Monotone piecewise cubic interpolation. SIAM Journal on Numerical Analysis
[2]: Hyman, J. M. (1983). Accurate monotonicity preserving cubic interpolation. SIAM Journal on Scientific and Statistical Computing
Metadata
Release files for binsmooth 2023.10.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| binsmooth-2023.10.0.tar.gz | 9.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| binsmooth-2023.10.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.0 kB
Release files / binsmooth-2023.10.0.tar.gz
| Download URL | binsmooth-2023.10.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87b046a90363e6e138152824216c549b2995cae76f2b8375403457846194dfa3
|
|
BLAKE2b-256 checksum How to use checksums |
59712374052457a5f733c74bc608775f6475ff3911e9d4051e726d0f5773c4fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Release files / binsmooth-2023.10.0-py3-none-any.whl
| Download URL | binsmooth-2023.10.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
076b6689bd477b2843e2aee13d4b48c6b30523f9f4e64b9b78a4c8c53837ed24
|
|
BLAKE2b-256 checksum How to use checksums |
f8ab781072682f65083baa2f99ce8da109ba5338788a52aea7f62367b5a3fb32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Security for binsmooth 2023.10.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.