Last active
December 25, 2015 00:59
-
-
Save mutaku/6891963 to your computer and use it in GitHub Desktop.
calculating h-indices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def h_index(pubs): | |
"""n-publicaions with at least n-citations""" | |
# sort the list of citations | |
pubs = sorted(pubs) | |
# iterate over the sorted list | |
for i, x in enumerate(pubs): | |
# number of citations including this one and greater | |
n = len(pubs[i:]) | |
# if this citaiton index is greater than or equal to | |
# n, we have an h_index | |
if x >= n: | |
return n | |
return False | |
In [78]: pubs = [43, 77, 3, 32, 2, 32, 4] | |
In [79]: h_index(pubs) | |
Out[79]: 4 | |
In [112]: h_index([800, 403, 420, 391]) | |
Out[112]: 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment