Samples integers from 1 to n with equal probability (with replacement),
analogous to R's sample.int(n, size, replace = TRUE).
Arguments
- shape
(
integer())
Shape.- initial_state
(
tensorish)
RNG state (ui64[2]).- n
(
integer(1))
Number of categories (samples integers1ton).- dtype
(
character(1)|stablehlo::TensorDataType)
Data type.
See also
Other rng:
nv_rbinom(),
nv_rng_state(),
nv_rnorm(),
nv_runif()
Examples
jit_eval({
state <- nv_rng_state(42L)
# Roll 6 dice
result <- nv_rdunif(6, state, n = 6L)
result[[2]]
})
#> AnvilTensor
#> 3
#> 5
#> 1
#> 4
#> 1
#> 1
#> [ CPUi32{6} ]