[EM] Simulations with social welfare functions
Jobst Heitzig
heitzig-j at web.de
Thu May 25 06:37:40 PDT 2006
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
More information about the Election-Methods
mailing list