gini 1.0.0 copy "gini: ^1.0.0" to clipboard
gini: ^1.0.0 copied to clipboard

A library for calculating the Gini coefficient

example/gini_example.dart

import 'package:gini/gini.dart';

void main() {

  // real world distribution
  List<double> incomes = [3000.12, 1200.29, 4500.01, 1600.89, 5200.11];
  double gini_coeffiecient = gini(incomes);
  print(gini_coeffiecient); // -> 0.2812325580495205

  // perfect equality distribution
  List<double> incomes2 = [1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0];
  double gini_coeffiecient2 = gini(incomes2);
  print(gini_coeffiecient2); // -> 0

  // inperfect equality distribution
  List<double> incomes3 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 10000000.0];
  double gini_coeffiecient3 = gini(incomes3);
  print(gini_coeffiecient3); // -> 0.9
}
0
likes
25
pub points
0%
popularity

Publisher

verified publisherdartsociety.dev

A library for calculating the Gini coefficient

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on gini