concentrationMetrics Package
This module provides the key concentrationMetrics objects
Index implements the main index calculation functionality
- class concentrationMetrics.model.Index(data=None, index=None, *args)[source]
Bases:
object
The concentration Index object provides the main interface to the various index calculations.
- atkinson(data, epsilon)[source]
Calculate the Atkinson inequality index.
- Parameters:
data (numpy array) – Positive numerical data
epsilon (float) – Index parameter
- Returns:
Atkinson inequality (Float)
Todo
Resolve divide by zero when N is very large
- average_clustering(adjacency_matrix)[source]
Calculate the Average Clustering Coefficient of an Adjacency Matrix.
- Parameters:
adjacency_matrix (matrix)
- Returns:
D (Float)
- berger_parker(data)[source]
Calculate the Berger-Parker Index (special version of the Concentration Ratio).
- Parameters:
data (numpy array) – Positive numerical data
- Returns:
Berger Parker (Float)
- compute(data, *args, ci=None, samples=None, index='hhi')[source]
Compute bootstrapped confidence interval estimates.
- Parameters:
data
args
ci
samples
index
- Returns:
- cr(data, n)[source]
Calculate the Concentration Ratio.
- Parameters:
data (numpy array) – Positive numerical data
n (int) – Integer selecting the top-n entries
- Returns:
Concentration Ratio (Float)
- Raise:
TypeError if n out of range
- ellison_glaeser(data, na, ni)[source]
Ellison and Glaeser (1997) indexes of industrial concentration.
Note
Implemented as in equation (5) of the original reference
Note
Input data are a data frame of three columns of the following type:
Exposure
Area
Industry
Float
Categorical
Categorical
Note
The ordering of the columns is important. The index is not symmetric with respect to area and industry factors
- Parameters:
data (pandas dataframe) – exposure data
na (integer) – number of areas
ni (integer) – number of industries
- Returns:
EG Indexes (list)
- gei(data, alpha)[source]
Calculate the Generalized Entropy Index.
- Parameters:
data (numpy array) – Positive numerical data
alpha – Index parameter
- Returns:
Generalized Entropy Index (Float)
- get_weights(data)[source]
Calculate data weights.
- Parameters:
data (numpy array) – Positive numerical data values
- Returns:
Vector of weights
- Raise:
ValueError if negative values
- gini(data)[source]
Calculate the Gini index.
- Parameters:
data (numpy array) – Positive numerical data
- Returns:
Gini (Float)
Note
The formula appears also with the opposite sign convention
- global_clustering(adjacency_matrix)[source]
Calculate the Global Clustering Coefficient of an Adjacency Matrix.
- Parameters:
adjacency_matrix (matrix)
- Returns:
D (Float)
- graph_density(adjacency_matrix)[source]
Calculate the Graph Density of an Adjacency Matrix.
- Parameters:
adjacency_matrix (matrix)
- Returns:
D (Float)
- hhi(data, normalized=True, ci=None, samples=None)[source]
Calculate the Herfindahl-Hirschman index.
- Parameters:
normalized (bool)
data (numpy array) – Positive numerical data
ci (float) – confidence interval
- Returns:
HHI (Float)
- hk(data, a)[source]
Calculate the inverted Hannah Kay index.
- Parameters:
data (numpy array) – Positive numerical data
a – Integer index parameter alpha
- Returns:
HK (Float)
- hoover(data)[source]
Calculate the Hoover index.
- Parameters:
data (numpy array) – Positive numerical data
- Returns:
Hoover (Float)
- hti(data)[source]
Calculate the Hall-Tideman index.
- Parameters:
data (numpy array) – Positive numerical data
- Returns:
HTI (Float)
- invsimpson(data)[source]
Calculate the Inverse Simpson index.
- Parameters:
data (numpy array) – Positive numerical data
- Returns:
Inverse Simpson (Float)
- kolm(data, alpha)[source]
Calculate the Kolm index.
- Parameters:
data (numpy array) – Positive numerical data
alpha – Index parameter
- Returns:
Kolm Index (Float)
- margalev(data)[source]
Calculate the Margalev index.
- Parameters:
data (list) – Categorical data
- Returns:
D (Float)
- network_entropy(adjacency_matrix)[source]
Calculate the Network Entropy of an Adjacency Matrix.
- Parameters:
adjacency_matrix (matrix)
- Returns:
D (Float)
- shannon(data, normalized=False)[source]
Calculate the Shannon entropy index.
- Parameters:
normalized (bool)
data (numpy array) – Positive numerical data
- Returns:
Shannon entropy (Float)
- simpson(data)[source]
Calculate the Simpson index.
- Parameters:
data (numpy array) – Positive numerical data
- Returns:
Simpson (Float)
- tango(data)[source]
Calculate the Tango temporal clustering index.
- Parameters:
data (list) – Categorical data
- Returns:
D (Float)