public static function npv(float $rate, array $values): float
    {
        $result = 0.0;

        for ($i = 0; $i < count($values); ++$i) {
            $result += $values[$i] / (1 + $rate)**$i;
        }

        return $result;
    }