Compute Gini Coefficient
Stick closely to the sources

It's helpful when coding math in cases like this to base your approach on established methods and language.

It might seem a bit extreme, but this can include:


Following a published method to the letter.
Linking to a readily-available description of it.
Naming your variables and laying out your code as closely as possible to that description.


eg.

def gini_index(*args*):
    """
    Calculates the Gini Index G given data of the form:
    *whatever form your data is*
    Using summation as described in:
    *reference* (can be textbook, arxiv etc)
    Via the formula:
    *include formulae if possible*
    Essentially as described here:
    https://en.wikipedia.org/wiki/Gini_coefficient#Alternate_expressions
    Example input:
    *your example input*
    Example output:
    *your example output*
    """
#   your code proper starts here


An example of this is here, a  collection of basic number theory and elliptic curve utilities that eventually became SageMath.

For example, were you actually to use this formula as a basis, you would name your counter i, your total number of values n, and use the summation functions provided in numpy. 

Trust me, if you think you'll revisit your code at a later date (when memory fails), or have it used or modified by someone else, this is a lifesaver.

(Edit: As you are integrating a polynomial, you can use the integ method of poly1d included with numpy rather than importing scipy.)