Skip to contents

Samples from a uniform distribution in the open interval (min, max).

Usage

nv_runif(shape, initial_state, dtype = NULL, min = 0, max = 1)

Arguments

shape

(integer())
Shape of the result.

initial_state

(arrayish)
RNG state: a 1-D array of two ui64 elements, as nv_rng_state() returns. The data type and length are fixed by the generator, not by the default data types, and the returned state has them too.

dtype

(NULL | character(1) | DataType)
Floating point data type. The default (NULL) uses the default float type.

min, max

(numeric(1))
Lower and upper bound.

Value

(named list of two arrayish)
Elements state, the updated RNG state, and values, the sample of shape shape and data type dtype.

Examples

# `state` is the updated RNG state, `values` the sample
state <- nv_rng_state(42L)
result <- nv_runif(c(2, 3), state)
result$values
#> AnvlArray
#>  0.8690 0.1506 0.5203
#>  0.3103 0.9928 0.1065
#> [ CPUf32{2,3} ]