Take an integer and convert it into an array of shuffled options.

@param integer $num Maximum index.
@return array
326486
public static function integerAsOptions($num)
    {
        $options = [];

        for ($i = 0; $i <= $num; $i++) {
            $options[] = $i;
        }

        shuffle($options);

        return $options;
    }
613291
protected function getIntegerOptionsBetween(int $min = null, int $max = null): array
    {
        $options = null;
        if (isset($min, $max)) {
            $options = array("options" => array("min_range" => $min, "max_range" => $max));
        } elseif (isset($min)) {
            $options = array("options" => array("min_range" => $min));
        } elseif (isset($max)) {
            $options = array("options" => array("max_range" => $max));
        }

        return $options;
    }
1252363
public function setNum($num = 20)
    {
        if (!is_numeric($num) && $num !== self::SEARCH_ALL) {
            throw new \InvalidArgumentException(
                'Argument can only be numeric or "all" to return all results.'
            );
        }
        $this->otherOptions['num'] = $num;

        return $this;
    }
1120502
public function arrayRand($array, $num = 1) {
    $keys = array_keys($array);
    $numKeys = sizeof($keys);
    if($num == 1) {
      return $keys[$this->int(0, $numKeys-1)];
    }

    for($i=0; $i < $num; $i++) {
      $picked[] = $keys[$this->int(0, $numKeys-1)];
    }
    return $picked;
  }
36822
public function topByPercent($num)
    {
        $count = $this->countData();
        return $this->top(round($num*$count/100));
    }
781727
protected function readIntegerList($num)
    {
        if ($this->littleEndian) {
            return unpack('V' . $num, fread($this->file, 4 * $num));
        }

        return unpack('N' . $num, fread($this->file, 4 * $num));
    }
353171
public function random($num = 1)
    {
        $count = \count($this->items);
        if ($num > $count) {
            $num = $count;
        }

        $this->items = array_intersect_key($this->items, array_flip((array)array_rand($this->items, $num)));

        return $this;
    }
711221
public function batchSize($num)
    {
        $this->batchSize = (integer) $num;
        $this->mongoCommandCursor->batchSize($num);

        return $this;
    }
1213290
protected static function getRandomBytes($num = 16)
    {
        static $which = null;
        if ($which === null) {
            if (\function_exists('\\random_bytes') && \version_compare(\phpversion(), '7.0.0', '>=')) {
                $which = 'php7';
            } elseif (\function_exists('\\openssl_random_pseudo_bytes')) {
                $which = 'openssl';
            } elseif (\function_exists('\\mcrypt_create_iv')) {
                $which = 'mcrypt';
            } elseif (\is_readable('/dev/urandom')) {
                $which = 'urandom';
            } else {
                $which = 'fallback';
            }
        }

        if ($num < 1 || $num > PHP_INT_MAX) {
            return false;
        }

        // Now let's get some random bytes
        switch ($which) {
            case 'php7':
                return \random_bytes($num);
            case 'mcrypt':
                return \mcrypt_create_iv($num, MCRYPT_DEV_URANDOM);
            case 'openssl';
                return \openssl_random_pseudo_bytes($num);
            case 'urandom':
                $fp = \fopen('/dev/urandom', 'rb');
                \stream_set_read_buffer($fp, 0);
                $bytes = \fread($fp, $num);
                \fclose($fp);
                return $bytes;
            default:
                // I really hope this is never necessary
                $bytes = '';
                for ($i = 0; $i < $num; ++$i) {
                    $bytes .= \chr(\mt_rand(0, 255) ^ \rand(0, 255));
                }

                $xorbuf = \sha1(\json_encode($_SERVER), true);
                while (self::safeStrlen($xorbuf) < $num) {
                    $xorbuf .= \sha1(
                        \uniqid(
                            \md5(
                                \microtime(true) . \lcg_value()
                            ),
                            true
                        ),
                        true
                    );
                }
                for ($i = 0; $i < $num; ++$i) {
                    $bytes[$i] ^= $xorbuf[$i];
                }

                return $bytes;
        }
    }
1023583
private function readAndHashBytes($num)
    {
        $bytes = $this->stream->read($num);
        hash_update($this->hashContext, $bytes);
        return $bytes;
    }
334115
public function drop( $num ) {
		if ( $num > $this->count() ) {
			$num = $this->count();
		}

		return $this->slice( $num, $this->count() );
	}
1290093
def permute(num):
    ""
    if permute_data:
        return np.random.permutation(num)
    else:
        logging.warning("Warning not permuting data")
        return np.arange(num)
179328
public function pop(int $num) : Collection
    {
        $ret = new Collection();
        foreach ($this -> iterator as $item) {
            if (!$num--)
                return $ret;
            $ret[] = unserialize(file_get_contents($item));
            unlink($item);
        }
        $this -> updateIterator();
        return $ret;
    }
431804
public function limit($num)
    {
        $num = (integer) $num;
        $this->limit = $num;
        $this->mongoCursor->limit($num);
        return $this;
    }
1018076
public function limit($num)
    {
        $num = (integer) $num;
        $this->limit = $num;
        $this->riakCursor->limit($num);
        return $this;
    }
729202
static public function numberToRoman($num) 
    {
        // Make sure that we only use the integer portion of the value
        $numr = intval($num);
        $result = '';

        // Declare a lookup array that we will use to traverse the number:
        $lookup = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1);

        foreach($lookup as $roman => $value) {
            // Determine the number of matches
            $matches = intval($numr / $value);

            // Store that many characters
            $result .= str_repeat($roman, $matches);

            // Substract that from the number
            $numr = $numr % $value;
        }

        // The Roman numeral should be built, return it
        return (string)$result;
    }
211891
protected function digits($param)
    {
        $digits = $param[0];

        if ($this->isNumeric()) {
            return [
                'min' => pow(10, $digits - 1),
                'max' => pow(10, $digits) - 1,
            ];
        }

        return [
            'pattern' => '\d{'.$digits.'}',
            'title' => $this->getTitle('digits', compact('digits')),
        ];
    }