mlx.core.random.randint

目錄

mlx.core.random.randint#

randint(low: scalar | array, high: scalar | array, shape: Sequence[int] = [], dtype: Dtype | None = int32, key: array | None = None, stream: StreamOrDevice = None) → array#

從指定區間產生隨機整數。

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

備註

The samples are drawn from a float32 uniform and clamped to [low, high - 1], so not every integer in the range is reachable once the bounds or the width of the interval go beyond the 2**24 integer resolution of float32.

參數:
  • low (scalar or array) -- Lower bound of the interval.

  • high (scalar or array) -- Upper bound of the interval.

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

  • dtype (Dtype, optional) -- Type of the output. Default: int32.

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

回傳值:

The array of random integers.

回傳值型別:

array