mlx.core.random.uniform#

mlx.core.random.uniform(low: Union[bool, int, float, complex, object] = 0, high: Union[bool, int, float, complex, object] = 1, shape: List[int] = [], dtype: Optional[Dtype] = mlx.core.float32, key: Optional[array] = None, stream: Union[None, Stream, Device] = None) array#

Generate uniformly distributed random numbers.

The values are sampled uniformly in the half-open interval [low, high). The lower and upper bound can be scalars or arrays and must be broadcastable to shape.

Parameters:
  • low (scalar or array, optional) – Lower bound of the distribution. Default is 0.

  • high (scalar or array, optional) – Upper bound of the distribution. Default is 1.

  • shape (list(int), optional) – Shape of the output. Default is ().

  • key (array, optional) – A PRNG key. Default: None.

  • dtype (Dtype, optional) – Type of the output. Default is float32.

Returns:

The output array random values.

Return type:

array