Dear Brian!
> data: 1, 1, 1, 999
> std: 499
> gini: 0.747005988023952
>From this you see that the Gini coefficient is something between 0 and
1, measuring the degree of inequality irrespective of the total.
By the way, the description on Wikipedia is much more complicated than
necessary, since it requires ordering of the values.
> Now to check my C code and get this implemented in my simulator.
> sub gini(@) {
> my $i;
> my $j;
> my $sum = 0.0;
> my $gs = 0.0;
> my @v = @_;
> for ( $i = 0; $i <= $#v; $i++ ) {
> $sum += $v[$i];
> for ( $j = $i + 1; $j <= $#v; $j++ ) {
> $gs += abs( $v[$i] - $v[$j] );
> }
> }
> return $gs / (($#v + 1) * $sum);
> }
The code seems correct. To get the Gini welfare function, you would now use
($sum - $gs/($#v+1)) / ($#v+1)
Yours, Jobst
----
election-methods mailing list - see http://electorama.com/em for list info