concentrationMetrics
concentrationMetrics copied to clipboard
Gini formula looks wrong (but works)
Looking for the formula here http://www.openriskmanual.org/wiki/Gini_Index

It seem that this code is wrong (but it works perfectly)
(1.0 - 2.0 * np.multiply(i, weights).sum())/n + 1.0
I think the right code would be:
(2.0 * np.multiply(i/n, weights).sum()) - (n - 1.0)/n
or following the other formula

(n + 1.0)/n - (2.0 * np.multiply((n + 1 - i)/n, weights).sum())
Those two codes that match the formulas have a problem, they get the results as negative numbers
Thanks for spotting this. The manual had the Gini formula with the opposite sign (both conventions are used). Modified the manual documentation so that it is consistent. The latest release includes some further tests (gini_test.py)
Fixed in documentation