"""This file defines helper function(s) to compute an "Equity" measure.These measures include:* Gini (https://en.wikipedia.org/wiki/Gini_coefficient)* Hoover (https://en.wikipedia.org/wiki/Hoover_index)"""importnumpyasnp
[docs]defhoover(values):""" Statistical measure of inequality. :param values: A list of integers, representing the distribution (incomes, comforts, ...). :return: A float between 0 (perfect equality) and 1 (perfect inequality). """iflen(values)==0:return0.0mean=np.mean(values)sum_xi=0sum_diff=0forxinvalues:sum_xi+=xsum_diff+=abs(x-mean)returnsum_diff/(2*sum_xi+10E-300)