liberata_metrics.metrics.distribution_metrics module

liberata_metrics.metrics.distribution_metrics.hhi_discrepancy(shares_matrix: spmatrix, mask_portfolio: slice) float[source]

Compute the discrepancy between the HHI of the field and that of the manuscript or portfolio. :param shares_matrix: Sparse matrix where each row represents a manuscript and each column represents an author.

Entries are the shares each author has for each given manuscript. This matrix should have all manuscripts in the field/discipline.

Parameters:

indices (np.array) – Array of indices of manuscripts in the shares_matrix that are to be considered in the HHI calculation.

Returns:

The HHID value, a measure of discrepancy between a portfolio and the industry. Higher values indicate an anomaly that should be further investigated.

Return type:

float

Examples

>>> hhi_discrepancy(shares_matrix, [1,2,5,6,7])
0.375
liberata_metrics.metrics.distribution_metrics.share_splits_inequality(portfolio: spmatrix) float[source]

Compute the Herfindahl-Hirschman Index (HHI) of a portfolio of manuscripts. :param portfolio: Sparse matrix where each row represents a manuscript and each column represents an author.

Entries are the shares each author has for each given manuscript.

Returns:

  • float – The mean HHI value, a measure of the typical concentration in the portfolio. Returns 0.0 if the portfolio is empty.

  • ——

  • TypeError – If portfolio is not a scipy sparse matrix.

Notes

  • The share splits inequality is calculated as the mean HHI of all provided manuscripts.

  • The HHI for a single manuscript is calculated as the sum of the squares of the share splits for that manuscript.

Examples

>>> share_splits_inequality(portfolio)
0.375