Inequality Coefficients:
This is small library with some implemented coefficients (or indices) intended to measure inequality or concentration of the values in a population.
Implemented coefficients
-
Gini Coefficient:
- Ordinary. Follows this formula:
- Corrected. Uses a correction for small datasets based on Deltas, 2003.
-
Ratio top / rest. Follows this formula:
Where k is is the ceil value for 100 - percentage you define.
For instance, if you take k = 10, you are getting the ratio of inequality between the top 10% percentage and the rest 90% percentage. In particular, this specific value of k is given to you directly by the ratio_top10_rest() function.
Installation
This library is hosted on PyPI, so installation is straightforward. The easiest way to install type this at the command line (Linux, Mac, or Windows):
pip install inequality_coefficients
This library also depends on numpy, but pip should take of that for
you already.
Basic Usage
For the simplest, typical use cases, this tells you everything you need to know.:
import inequality_coefficients as ineq
data = array([1.7, 3.2 ...]) # data can be list of nums or numpy array
gini_coeff = ineq.gini(data)
ratio_top_rest = ineq.ratio_top10_rest(data)
Development
To setup the development environment install all the dev dependiencies with pip install -r requirements.txt and install the latest version in your sites-packages with python setup.py develop.
Run tests
I use pytest. Install it with pip install -U pytest and run the test with the development setup with pytest.
Acknowledgements
Firstly, I was based on Felipe Ortega's wikixray code for implementing the gini coefficient, however, my code has changed so much (I have even fixed a bug in his code) and also now I'm using numpy as backend.
Anyway, I want to thank him for open sourcing that project.
Metadata
Release files for inequality-coefficients 1.2.3
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 | Actions |
|---|---|---|---|---|
| inequality_coefficients-1.2.3.tar.gz | 3.3 kB | Without provenance | Details for inequality_coefficients-1.2.3.tar.gz |
Release files / inequality_coefficients-1.2.3.tar.gz
| Download URL | inequality_coefficients-1.2.3.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
876b3c02dabb64c75059b46fc31fe3ea934d80db8d567fa0791272243aef93ea
|
|
BLAKE2b-256 checksum How to use checksums |
0964f398fc0684471b12342cfbbafa1f73736ec39cec7d0a9d4ccba785ac62f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
|
Security for inequality-coefficients 1.2.3
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.