Algorithm for Gini Coefficient:

Since Gini is the ratio of areas under a curve, it is relatively easy to compute using simple methods.

Also since much of the data on income distribution is provided as mean income level per quintile plus the top 5%, it is possible to use a simple algorithm to compute the area.

 

Since Gini is the ratio of areas, it is not a sensitive or fast moving number.

 

Gini coeff is the area between the 45 degree line and the Lorenz curve divided by the area below the Lorenz curve.

 

A video explaining the basics of the Gini calculation:   from England

 

Paper on how to calculate this distribution number:  Link

There are several ways to compute the Gini coefficient for a dataset. 
 
Researchers who are comfortable with Calculus and spreadsheet analysis and have a large amount of data that results in smooth plots can estimate a high order polynomial for the Lorenz Curve (Microsoft Excel will add up to a 6th degree polynomial as a trend line for an XY graph), and then take an appropriate integral to compute the size of the shaded area.  Likewise, other estimation techniques, such as the method of rectangles, the method of trapezoids, or Monte Carlo integration will provide reasonable estimates. 
 
Another way to compute the Gini is directly from an algebraic formula.  Given that the data is ordered from smallest to largest values of the variable of interest, the formula is:   (Equation)
 
To compute the Gini coefficients for the sample data, it is easiest to organize the data such that each individual is given his or her own record (such that the salary schedule for Universal Widget has 400 rows, one for each employee).  After splitting the data in this manner, it is fairly straightforward to apply the formula above.  For Universal Widget, the Gini coefficient is 0.279625369, while for Worldwide Widget, the Gini coefficient is 0.227509252. 
The Gini coefficient is a full-information measure, looking at all parts of the distribution.  It is probably the most well-known and broadly used measure of inequality used in economic literature. 
The Gini coefficient facilitates direct comparison of two populations, regardless of their sizes.  In other words, with the Gini coefficient one can directly compare the inequality in a classroom to the inequality in a country.  While the actual computation of the Gini coefficient may include taking an integral or using a slightly complex formula, the visual description is elegant and easy to understand. 
The Gini coefficient does suffer from the lack of a true zero, and the need for a context. 
While a distributional policy, like giving everyone below the poverty line $1,000, has real implications, the repercussions of a 5% reduction of the Gini coefficient are much less clear. 
 

 

Gini can certainly be estimated using simple integration approach in a spreadsheet.