pub fn batched_uniform<B: Backend, T: Float>(
keys: &Key<B>,
shape: impl Into<Shape>,
minval: impl ArrayLike<B, T>,
maxval: impl ArrayLike<B, T>,
) -> Array<B, T>Expand description
Uniform random floats in [minval, maxval) for each key of an array of
keys (u32[*batch, 2]), of shape [*batch, *shape]: JAX’s
jax.vmap(lambda k: jax.random.uniform(k, shape, minval, maxval))(keys)
(one vmap per batch dimension), with the keys hashed together as JAX’s
batched threefry2x32 hashes them. minval and maxval broadcast
against the result, as unbatched operands of the vmapped function.
§Examples
use ruxla_core::{Native, random};
let keys = random::split(&random::key::<Native>(0), 3);
let u = random::batched_uniform::<Native, f32>(&keys, [2], 0.0, 1.0);
assert_eq!(u.shape().dims(), &[3, 2]);
for i in 0..3 {
let one = random::uniform::<Native, f32>(&keys.get(i), [2], 0.0, 1.0);
assert_eq!(u.to_vec()[2 * i..2 * i + 2], one.to_vec());
}§Panics
Panics if keys is a single key (use uniform).