Samples integers from 1 to n with equal probability and with
replacement, analogous to R's sample.int().
To sample from a population other than 1:n, use nv_sample().
Value
(list() of arrayish)
List of two elements: the updated RNG state and the sampled integers,
of shape shape.
See also
nv_sample() to sample from an arbitrary population.
Other rng:
nv_normal,
nv_rbinom(),
nv_rng_state(),
nv_runif(),
nv_sample()
Examples
state <- nv_rng_state(42L)
# Roll 6 dice
result <- nv_sample_int(6, state, 6L)
result[[2]]
#> AnvlArray
#> 4
#> 6
#> 2
#> 5
#> 1
#> 2
#> [ CPUi32{6} ]