-
-
Save esagara/cfd94c5ffbd58d157291 to your computer and use it in GitHub Desktop.
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
pop = [1.0,2.0,3.0] | |
#total = reduce(lambda x,y: x + y, pop) - no lambdas for me | |
total = sum(pop) | |
# cummulative = reduce(lambda x,(i,y): x + y * (len(pop) - i - 1),enumerate(pop)) - doesn't work cuz python | |
cummulative = 0 | |
for i,x in enumerate(pop): | |
cummulative += x * (len(pop) - i - 1) | |
area = (cummulative/total + 0.5) / len(pop) | |
gini = (2 * (0.5 - area)) | |
print gini |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment