/NumPy 1.14

# numpy.random.random_integers

`numpy.random.random_integers(low, high=None, size=None)`

Random integers of type np.int between `low` and `high`, inclusive.

Return random integers of type np.int from the “discrete uniform” distribution in the closed interval [`low`, `high`]. If `high` is None (the default), then results are from [1, `low`]. The np.int type translates to the C long type used by Python 2 for “short” integers and its precision is platform dependent.

This function has been deprecated. Use randint instead.

Deprecated since version 1.11.0.

Parameters: low : int Lowest (signed) integer to be drawn from the distribution (unless `high=None`, in which case this parameter is the highest such integer). high : int, optional If provided, the largest (signed) integer to be drawn from the distribution (see above for behavior if `high=None`). size : int or tuple of ints, optional Output shape. If the given shape is, e.g., `(m, n, k)`, then `m * n * k` samples are drawn. Default is None, in which case a single value is returned. out : int or ndarray of ints `size`-shaped array of random integers from the appropriate distribution, or a single such random int if `size` not provided.

`random.randint`
Similar to `random_integers`, only for the half-open interval [`low`, `high`), and 0 is the lowest value if `high` is omitted.

#### Notes

To sample from N evenly spaced floating-point numbers between a and b, use:

```a + (b - a) * (np.random.random_integers(N) - 1) / (N - 1.)
```

#### Examples

```>>> np.random.random_integers(5)
4
>>> type(np.random.random_integers(5))
<type 'int'>
>>> np.random.random_integers(5, size=(3,2))
array([[5, 4],
[3, 3],
[4, 5]])
```

Choose five random numbers from the set of five evenly-spaced numbers between 0 and 2.5, inclusive (i.e., from the set ):

```>>> 2.5 * (np.random.random_integers(5, size=(5,)) - 1) / 4.
array([ 0.625,  1.25 ,  0.625,  0.625,  2.5  ])
```

Roll two six sided dice 1000 times and sum the results:

```>>> d1 = np.random.random_integers(1, 6, 1000)
>>> d2 = np.random.random_integers(1, 6, 1000)
>>> dsums = d1 + d2
```

Display results as a histogram:

```>>> import matplotlib.pyplot as plt
>>> count, bins, ignored = plt.hist(dsums, 11, normed=True)
>>> plt.show()
``` © 2008–2017 NumPy Developers
{"ft_lang_label":"__label__en","ft_lang_prob":0.64698315,"math_prob":0.98759055,"size":1982,"snap":"2019-35-2019-39","text_gpt3_token_len":571,"char_repetition_ratio":0.16986856,"word_repetition_ratio":0.033444814,"special_character_ratio":0.32038346,"punctuation_ratio":0.23853211,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9978795,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-19T02:17:28Z\",\"WARC-Record-ID\":\"<urn:uuid:ee2fc347-cafa-4688-8514-ebff2cb9d5d0>\",\"Content-Length\":\"19852\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:3cb6ec5c-5f69-4cf8-ba9c-282a819df191>\",\"WARC-Concurrent-To\":\"<urn:uuid:1a02ff35-f991-465e-9859-7e9798a40a5f>\",\"WARC-IP-Address\":\"185.199.111.153\",\"WARC-Target-URI\":\"https://docs.w3cub.com/numpy~1.14/generated/numpy.random.random_integers/\",\"WARC-Payload-Digest\":\"sha1:IWD73TTJSWCZXRDBPCOXBEX3CHP4XXYR\",\"WARC-Block-Digest\":\"sha1:5GDYWITIO4GYWIN45KNIG7CLOA3XSEWW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514573415.58_warc_CC-MAIN-20190919015534-20190919041534-00101.warc.gz\"}"}