bundles / numpy latest / numpy / random / RandomState / random_integers
cython_function_or_method
numpy.random:RandomState.random_integers
Signature
def random_integers ( low , high = None , size = None ) Summary
Random integers of type numpy.int_ between low and high, inclusive.
Extended Summary
Return random integers of type numpy.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 numpy.int_ type translates to the C long integer type and its precision is platform dependent.
This function has been deprecated. Use randint instead.
Parameters
low: intLowest (signed) integer to be drawn from the distribution (unless
high=None, in which case this parameter is the highest such integer).high: int, optionalIf provided, the largest (signed) integer to be drawn from the distribution (see above for behavior if
high=None).size: int or tuple of ints, optionalOutput shape. If the given shape is, e.g.,
(m, n, k), thenm * n * ksamples are drawn. Default is None, in which case a single value is returned.
Returns
out: int or ndarray of intssize-shaped array of random integers from the appropriate distribution, or a single such random int ifsizenot provided.
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)
✗type(np.random.random_integers(5))
✓np.random.random_integers(5, size=(3,2))
✗2.5 * (np.random.random_integers(5, size=(5,)) - 1) / 4.
✗d1 = np.random.random_integers(1, 6, 1000) d2 = np.random.random_integers(1, 6, 1000) dsums = d1 + d2✓
import matplotlib.pyplot as plt count, bins, ignored = plt.hist(dsums, 11, density=True) plt.show()✓

See also
- randint
Similar to
random_integers, only for the half-open interval [low,high), and 0 is the lowest value ifhighis omitted.
Aliases
-
numpy.random.random_integers -
numpy.random.RandomState.random_integers