cyjax.random.real_sphere#

cyjax.random.real_sphere(key, shape)#

Random points on real unit sphere.

The last value in the shape tuple is interpreted as dimension \(n\) such that the points lie on the sphere \(S^{n-1}\) of unit radius in \(\mathbb{R}^n\).

Example

>>> x = real_sphere(jax.random.PRNGKey(0), (4, 3))
>>> jnp.allclose(jnp.linalg.norm(x, axis=-1), 1)
DeviceArray(True, dtype=bool)
Parameters:
  • key (Union[PRNGKeyArray, Array]) – PRNG random key.

  • shape (Sequence[Union[int, Any]]) – Tuple of nonnegative integers. Last value is interpreted as dimension of (ambient) real vector space.

Returns:

Array of requested shape containing real values.