larray.random.randint

larray.random.randint(low, high=None, axes=None, dtype='l', meta=None)[source]

Return random integers from low (inclusive) to high (exclusive).

Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [low, high). If high is None (the default), then results are from [0, low).

Parameters
lowint

Lowest (signed) integer to be drawn from the distribution (unless high=None, in which case this parameter is one above the highest such integer).

highint, optional

If provided, one above the largest (signed) integer to be drawn from the distribution (see above for behavior if high=None).

axesint, tuple of int, str, Axis or tuple/list/AxisCollection of Axis, optional

Axes (or shape) of the resulting array. If axes is None (the default), a single value is returned. Otherwise, if the resulting axes have a shape of, e.g., (m, n, k), then m * n * k samples are drawn.

dtypedata-type, optional

Desired dtype of the result. All dtypes are determined by their name, i.e., ‘int64’, ‘int’, etc, so byteorder is not available and a specific precision may have different C types depending on the platform. The default value is ‘np.int’.

metalist of pairs or dict or OrderedDict or Metadata, optional

Metadata (title, description, author, creation_date, …) associated with the array. Keys must be strings. Values must be of type string, int, float, date, time or datetime.

Returns
LArray

Examples

Generate a single int between 0 and 9, inclusive:

>>> la.random.randint(10)                                   # doctest: +SKIP
6

Generate an array of 10 ints between 1 and 5, inclusive:

>>> la.random.randint(1, 6, 10)                             # doctest: +SKIP
{0}*  0  1  2  3  4  5  6  7  8  9
      1  1  5  1  5  4  3  4  2  1

Generate a 2 x 3 array of ints between 0 and 4, inclusive:

>>> la.random.randint(5, axes=(2, 3))                       # doctest: +SKIP
{0}*\{1}*  0  1  2
        0  4  4  1
        1  1  2  2
>>> la.random.randint(5, axes='a=a0,a1;b=b0..b2')           # doctest: +SKIP
a\b  b0  b1  b2
 a0   0   3   1
 a1   4   0   1