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

Open Risk Manual Entry for Atkinson Index

average_clustering(adjacency_matrix)[source]

Calculate the Average Clustering Coefficient of an Adjacency Matrix.

Parameters:

adjacency_matrix (matrix)

Returns:

D (Float)

Open Risk Manual Entry for Average Clustering

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)

Open Risk Manual Entry for Berger-Parker Index

call_method(name, data, *args)[source]
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

Open Risk Manual Entry for Concentration Ratio

describe(index)[source]
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)

Open Risk Manual Entry for Ellison-Glaeser Index

gei(data, alpha)[source]

Calculate the Generalized Entropy Index.

Parameters:
  • data (numpy array) – Positive numerical data

  • alpha – Index parameter

Returns:

Generalized Entropy Index (Float)

Open Risk Manual Entry for Generalized Entropy Index

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

Open Risk Manual Entry for Gini Index

global_clustering(adjacency_matrix)[source]

Calculate the Global Clustering Coefficient of an Adjacency Matrix.

Parameters:

adjacency_matrix (matrix)

Returns:

D (Float)

Open Risk Manual Entry for Global Clustering

graph_density(adjacency_matrix)[source]

Calculate the Graph Density of an Adjacency Matrix.

Parameters:

adjacency_matrix (matrix)

Returns:

D (Float)

Open Risk Manual Entry for Graph Density

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)

Open Risk Manual Entry for the Hirschman-Herfindahl Index

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)

Open Risk Manual Entry for Hannah Kay Index

hoover(data)[source]

Calculate the Hoover index.

Parameters:

data (numpy array) – Positive numerical data

Returns:

Hoover (Float)

Open Risk Manual Entry for Hoover Index

hti(data)[source]

Calculate the Hall-Tideman index.

Parameters:

data (numpy array) – Positive numerical data

Returns:

HTI (Float)

Open Risk Manual Entry for Hall-Tideman Index

invsimpson(data)[source]

Calculate the Inverse Simpson index.

Parameters:

data (numpy array) – Positive numerical data

Returns:

Inverse Simpson (Float)

Open Risk Manual Entry for Inverse Simpson Index

kolm(data, alpha)[source]

Calculate the Kolm index.

Parameters:
  • data (numpy array) – Positive numerical data

  • alpha – Index parameter

Returns:

Kolm Index (Float)

Open Risk Manual Entry for Kolm Index

margalev(data)[source]

Calculate the Margalev index.

Parameters:

data (list) – Categorical data

Returns:

D (Float)

Open Risk Manual Entry for Margalev Index

network_entropy(adjacency_matrix)[source]

Calculate the Network Entropy of an Adjacency Matrix.

Parameters:

adjacency_matrix (matrix)

Returns:

D (Float)

Open Risk Manual Entry for Network Entropy

print(cols=None)[source]
shannon(data, normalized=False)[source]

Calculate the Shannon entropy index.

Parameters:
  • normalized (bool)

  • data (numpy array) – Positive numerical data

Returns:

Shannon entropy (Float)

Open Risk Manual Entry for Shannon Entropy Index

simpson(data)[source]

Calculate the Simpson index.

Parameters:

data (numpy array) – Positive numerical data

Returns:

Simpson (Float)

Open Risk Manual Entry for Simpson Index

tango(data)[source]

Calculate the Tango temporal clustering index.

Parameters:

data (list) – Categorical data

Returns:

D (Float)

Open Risk Manual Entry for Tango Clustering Index

theil(data)[source]

Calculate the Theil Index (Generalized Entropy Index for a=1).

Parameters:

data (numpy array) – Positive numerical data

Returns:

Theil Index (Float)

Open Risk Manual Entry for Theil Index

total_size(data)[source]