Math, programming, ecology, and more

Gini Coefficients and the Olympic Medal Race

Today’s post will attempt to answer a provocative question: is the race for Olympic medal dominance getting more competitive? In the process of addressing this topic, we’ll learn how to directly import data from WolframAlpha into Mathematica.

If you watched any of the Olympics over the past two weeks, you likely became familiar with the medal count table. This table is a grossly reductionist metric of national achievement at the Olympics. Nonetheless, it provides a useful way to quantify the aggregate performance of different nations.

The United States took home 104 medals from the 2012 games, placing it at the top of the medal table. The race for the most medals was exciting, though, as China and Russia were not far behind.

Competitive balance among nations generates excitement. Parity is what makes things interesting. If one nation dominated the podium, the Olympics would be boring.

Is the competitive balance between nations improving or declining? One way to address this question is to look at the distribution of medals won by different nations. When most of the medals are won by a very few nations, competitive balance is poor; when medals are distributed more equally among nations, competitive balance is stronger.

The Gini coefficient is a statistic widely used by economists to measure income inequality. The Gini coefficient is proportional to the average difference between individual incomes in a population, normalized to fall between 0 and 1. A Gini coefficient of 0 indicates total equality; a Gini coefficient of 1 indicates all income is controlled by a single individual. We can use the same statistic to quantify inequality in Olympic medal winnings.

First, however, we need to find data on Olympic medals. This is particularly easy in Mathematica 8, due to its interface with WolframAlpha. For the uninitiated, WolframAlpha is a bit like a search engine. Rather than direct you to relevant webpages, though, it attempts to answer you query with data. If you type in a math problem, it will try to solve it. If you type in a request for data, it will display the results in a table.

You needn’t visit the WolframAlpha website to do a search. Instead, you can access it directly in Mathematica by typing WolframAlpha[“search item”]. For example, typing WolframAlpha[“2012 Olympic Medals”] yields the following output:

Clicking the “more” button in the upper right corner will expand the results to include all nations that won medals. The format of the output is the same “pod” format that you’ll see on WolfrmaAlpha’s website. To actually make use of the data, hit the plus symbol in the upper right corner and choose “computable data”. You can save the result as something like “medals2012”.

Now we turn to the Gini Coefficient to see how medal inequality changes over the years. (Relax math folks; I mean inequality in the economic sense).

Below is the code for calculating Gini coefficients. Note the use of the command “Empirical Distribution”. This is another new feature in Mathematica 8. Given a data set, it generates the probability distribution, allowing you to directly use the associated probability density function and cumulative distribution function.

1

2

3

4

5

6

7

gini[list_]:=

Module[{d},d=EmpiricalDistribution[list];

1-Sum[(

PDF[d,

y]*(Sum[PDF[d,x]*x,{x,0,y-1}]+Sum[PDF[d,x]*x,{x,0,y}]))/

Sum[PDF[d,x]*x,{x,1,Max[list]}],{y,1,Max[list]}]// N]

ginis=Map[gini[#] &amp;, medals];

A couple caveats are in order. First, we are only considering the distribution of medals among medal winning nations. Many nations attend the Olympics symbolically, but are not in serious medal contention. These are not included in this calculation. Furthermore, we only consider the total medal count, and hence golds, silvers, and bronzes are treated as equal achievements, which they are obviously are not.