diff --git a/Math/Finance/Lorenzkurve.php b/Math/Finance/Lorenzkurve.php new file mode 100644 index 000000000..ea7ca8d16 --- /dev/null +++ b/Math/Finance/Lorenzkurve.php @@ -0,0 +1,45 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Math\Finance; + +/** + * Finance class. + * + * @category Log + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Lorenzkurve +{ + public static function getGiniCoefficient(array $data) + { + $sum1 = 0; + $sum2 = 0; + $i = 1; + $n = count($data); + + foreach ($data as $key => $value) { + $sum1 += $i * $value; + $sum2 += $value; + } + + return 2 * $sum1 / ($n * $sum2) - ($n + 1) / $n; + } +} \ No newline at end of file