mlx.core.random.normal

Contents

mlx.core.random.normal#

normal(shape: Sequence[int] = [], dtype: Dtype | None = float32, loc: scalar | array | None = None, scale: scalar | array | None = None, key: array | None = None, stream: None | Stream | Device = None) array#

Generate normally distributed random numbers.

If loc and scale are not provided the “standard” normal distribution is used. That means $x sim mathcal{N}(0, 1)$ for real numbers and $text{Re}(x),text{Im}(x) sim mathcal{N}(0, frac{1}{2})$ for complex numbers.

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

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

  • loc (scalar or array, optional) – Mean of the distribution. Default: None.

  • scale (scalar or array, optional) – Standard deviation of the distribution. Default: None.

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

Returns:

The output array of random values.

Return type:

array