Samples from a uniform distribution in the open interval (min, max).
Arguments
- shape
(
integer())
Shape of the result.- initial_state
(
arrayish)
RNG state: a 1-D array of twoui64elements, asnv_rng_state()returns. The data type and length are fixed by the generator, not by the default data types, and the returnedstatehas 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.
See also
Other rng:
nv_normal,
nv_rbinom(),
nv_rng_state(),
nv_sample(),
nv_sample_int()
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} ]