public function getArrayKeyByPowers(array $powers)
    {
        if (empty($powers)) {
            throw new InvalidArgumentException('Empty powers set');
        }

        $powersSum = 0;
        foreach ($powers as $power) {
            if ($power < 0) {
                throw new InvalidArgumentException('Negative power found');
            }

            $powersSum += $power;
        }

        if ($powersSum <= 0) {
            throw new InvalidArgumentException('The sum of powers must be positive');
        }

        $randomValue = $this->generator->getFloat(0, $powersSum);
        $currentSum = 0;
        $result = null;
        foreach ($powers as $key => $power) {
            $currentSum += $power;
            if ($currentSum >= $randomValue) {
                $result = $key;
                break;
            }
        }

        return $key;
    }