mlx.core.random.bernoulli

目錄

mlx.core.random.bernoulli#

bernoulli(p: scalar | array = 0.5, shape: Sequence[int] | None = None, key: array | None = None, stream: None | Stream | Device = None) array#

產生伯努利隨機值。

The values are sampled from the bernoulli distribution with parameter p. The parameter p can be a float or array and must be broadcastable to shape.

參數:
  • p (float or array, optional) -- Parameter of the Bernoulli distribution. Default: 0.5.

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

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

回傳:

The array of random integers.

回傳型別:

array