Skip to contents

Samples from a uniform distribution in the open interval (lower, upper).

Usage

nv_runif(shape, initial_state, dtype = "f32", lower = 0, upper = 1)

Arguments

shape

(integer())
Shape.

initial_state

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

dtype

(character(1) | stablehlo::TensorDataType)
Data type.

lower, upper

(numeric(1))
Lower and upper bound.

Value

(list() of tensorish)
List of two elements: the updated RNG state and the sampled values.

Examples

jit_eval({
  state <- nv_rng_state(42L)
  result <- nv_runif(c(2, 3), state)
  result[[2]]
})
#> AnvilTensor
#>  0.8690 0.1506 0.5203
#>  0.3103 0.9928 0.1065
#> [ CPUf32{2,3} ]