Skip to contents

Samples integers from 1 to n with equal probability (with replacement), analogous to R's sample.int(n, size, replace = TRUE).

Usage

nv_rdunif(shape, initial_state, n, dtype = "i32")

Arguments

shape

(integer())
Shape.

initial_state

(arrayish)
RNG state (ui64[2]).

n

(integer(1))
Number of categories (samples integers 1 to n).

dtype

(character(1) | tengen::DataType)
Data type.

Value

(list() of arrayish)
List of two elements: the updated RNG state and the sampled integers.

Examples

state <- nv_rng_state(42L)
# Roll 6 dice
result <- nv_rdunif(6, state, n = 6L)
result[[2]]
#> AnvlArray
#>  3
#>  5
#>  1
#>  4
#>  1
#>  1
#> [ CPUi32{6} ]