flopscope.numpy.random.RandomState.tomaxint
fnp.random.RandomState.tomaxint(self, size=None)
Return a sample of uniformly distributed random integers in the interval [0, ``flops.iinfo("long").max``].
Adapted from NumPy docs np.random.RandomState.tomaxint
Legacy max-int sampler; cost = numel(output).
Return a sample of uniformly distributed random integers in the interval [0, flops.iinfo("long").max].
This function uses the C-long dtype, which is 32bit on windows and otherwise 64bit on 64bit platforms (and 32bit on 32bit ones). Since NumPy 2.0, NumPy's default integer is 32bit on 32bit platforms and 64bit on 64bit platforms.
Parameters
- size:int or tuple of ints, optional
Output 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:ndarray
Drawn samples, with shape size.
See also
- randint Uniform sampling over a given half-open interval of integers.
- random_integers Uniform sampling over a given closed interval of integers.
Examples
>>> rs = flops.random.RandomState() # need a RandomState object
>>> rs.tomaxint((2,2,2))
array([[[1170048599, 1600360186], # random
[ 739731006, 1947757578]],
[[1871712945, 752307660],
[1601631370, 1479324245]]])
>>> rs.tomaxint((2,2,2)) < flops.iinfo(flops.int_).max
array([[[ True, True],
[ True, True]],
[[ True, True],
[ True, True]]])