Skip to main content

A python library for the computation of various concentration, inequality and diversity indices

Project description

The concentrationMetrics Library

concentrationMetrics is an MIT-licensed Python package aimed at becoming a reference implementation of indexes used in the analysis of concentration, inequality and diversity measures.

Overview of Main Features

  • exhaustive collection of concentration and inequality indexes and metrics

  • supports file input/output in both json and csv formats

  • detailed mathematical documentation

  • computation of confidence intervals via bootstraping

  • visualization using matplotlib

Usage

Using the library is quite straightforward. For example calculating the Gini and the HHI indexes on randomly generated portfolio data:

import numpy as np
from concentrationMetrics import Index

# Create some data
a = 1.7
portfolio = np.random.zipf(a, 100)

# Calculate the desired indexes
indices = Index()
hhi = indices.hhi(portfolio)
gini = indices.gini(portfolio)

# Compute the confidence interval around the HHI index value
lower_bound, val, upper_bound = indices.compute(portfolio, index='hhi', ci=0.95, samples=10000)

# Calculate indexes on a dataframe
BCI = pd.read_json(dataset_path + "BCI.json")
y = BCI.values
myGroupIndex = cm.Index(data=y, index='simpson')
myGroupIndex.print(6)

Many more examples and tests are available in the examples and test directories.

File structure

  • concentrationMetrics/model.py The library module

  • datasets/ Contains a variety of datasets useful for getting started with the ConcentrationMetrics

  • examples/ Variety of usage examples

  • docs/ Sphinx generated documentation

  • tests/ testing the implementation

All indexes are currently implemented in concentrationMetrics/model.py as methods of the Index object.

Dependencies

The main dependencies are the standard python datascience stack (numpy, pandas etc) and networkx. The full list is in requirements.txt

  • matplotlib

  • numpy

  • pandas

  • scipy

  • networkx

Datasets

Version 0.5.0 includes datasets used primarily for testing and comparison with R implementations:

  • hhbudget.csv

  • Ilocos.csv

  • BCI.json

Comparison with R packages

  • atkinson_test.py compares the Atkinson function with the IC2/Atk function

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

concentrationMetrics-0.6.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

concentrationMetrics-0.6.0-py2.py3-none-any.whl (18.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file concentrationMetrics-0.6.0.tar.gz.

File metadata

  • Download URL: concentrationMetrics-0.6.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for concentrationMetrics-0.6.0.tar.gz
Algorithm Hash digest
SHA256 9c4e169f0a19ef16cc6c318de51897d9eeffd7967197126e26d76eaf21921e49
MD5 1205b81d9150ee6b541ba4291f77a4ec
BLAKE2b-256 d6032d4164f818058f4e489e13139178c8440fcd3a45f9ff3591eb6ce91c2311

See more details on using hashes here.

File details

Details for the file concentrationMetrics-0.6.0-py2.py3-none-any.whl.

File metadata

  • Download URL: concentrationMetrics-0.6.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for concentrationMetrics-0.6.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 29dc03281af8e93c927f3ebdbe557b33bf3e4b57a4ff33eac06133569183c073
MD5 028b2989c39b7284480f0ea6063b6c95
BLAKE2b-256 65a13a2fb6187f47ef4d03feef269fdce444948d9ddd5634ae822345b3ef00bd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page