Skip to content

dq.random.real

real(
    key: PRNGKeyArray,
    shape: int | tuple[int, ...],
    *,
    min: float = 0.0,
    max: float = 1.0
) -> Array

Returns an array of uniformly distributed random real numbers.

Each element of the returned array is sampled uniformly in \([\text{min}, \text{max})\).

Parameters

  • key –

    A PRNG key used as the random key.

  • shape (int or tuple of ints) –

    Shape of the returned array.

  • min –

    Minimum (inclusive) value.

  • max –

    Maximum (exclusive) value.

Returns

(array of shape (*shape)) Random real number array.

Examples

>>> key = jax.random.PRNGKey(42)
>>> dq.random.real(key, (2, 5), max=5.0)
Array([[3.22 , 1.613, 0.967, 4.432, 4.21 ],
       [0.96 , 1.726, 1.262, 3.16 , 3.274]], dtype=float32)