bernoulli#

ivy.bernoulli(probs, *, logits=None, shape=None, device=None, dtype=None, seed=None, out=None)[source]#

Draws samples from Bernoulli distribution parameterized by probs or logits (but not both)

Parameters:
  • logits (Optional[Union[float, NativeArray, Array]], default: None) – An N-D Array representing the log-odds of a 1 event. Each entry in the Array parameterizes an independent Bernoulli distribution where the probability of an event is sigmoid (logits). Only one of logits or probs should be passed in.

  • probs (Union[float, Array, NativeArray]) – An N-D Array representing the probability of a 1 event. Each entry in the Array parameterizes an independent Bernoulli distribution. Only one of logits or probs should be passed in

  • shape (Optional[Union[Shape, NativeShape]], default: None) – If the given shape is, e.g ‘(m, n, k)’, then ‘m * n * k’ samples are drawn. (Default value = ‘None’, where ‘ivy.shape(logits)’ samples are drawn)

  • device (Optional[Union[Device, NativeDevice]], default: None) – device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None).

  • dtype (Optional[Union[Dtype, NativeDtype]], default: None) – output array data type. If dtype is None, the output array data type will be the default floating-point data type. Default None

  • seed (Optional[int], default: None) – A python integer. Used to create a random seed distribution

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Array

Returns:

ret – Drawn samples from the Bernoulli distribution

Array.bernoulli(self, *, logits=None, shape=None, device=None, dtype=None, seed=None, out=None)[source]#
Parameters:
  • self (Array) – An N-D Array representing the probability of a 1 event. Each entry in the Array parameterizes an independent Bernoulli distribution. Only one of logits or probs should be passed in

  • logits (Optional[Union[float, Array, NativeArray]], default: None) – An N-D Array representing the log-odds of a 1 event. Each entry in the Array parameterizes an independent Bernoulli distribution where the probability of an event is sigmoid (logits). Only one of logits or probs should be passed in.

  • shape (Optional[Union[Shape, NativeShape]], default: None) – If the given shape is, e.g ‘(m, n, k)’, then ‘m * n * k’ samples are drawn. (Default value = ‘None’, where ‘ivy.shape(logits)’ samples are drawn)

  • device (Optional[Union[Device, NativeDevice]], default: None) – device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None).

  • dtype (Optional[Union[Dtype, NativeDtype]], default: None) – output array data type. If dtype is None, the output array data type will be the default floating-point data type. Default None

  • seed (Optional[int], default: None) – A python integer. Used to create a random seed distribution

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Returns:

ret – Drawn samples from the Bernoulli distribution

Container.bernoulli(self, /, *, logits=None, shape=None, device=None, dtype=None, seed=None, out=None)[source]#
Parameters:
  • self (Container) – An N-D Array representing the probability of a 1 event. Each entry in the Array parameterizes an independent Bernoulli distribution. Only one of logits or probs should be passed in.

  • logits (Optional[Union[float, Array, NativeArray, Container]], default: None) – An N-D Array representing the log-odds of a 1 event. Each entry in the Array parameterizes an independent Bernoulli distribution where the probability of an event is sigmoid(logits). Only one of logits or probs should be passed in.

  • shape (Optional[Union[Shape, NativeShape, Container]], default: None) – If the given shape is, e.g ‘(m, n, k)’, then ‘m * n * k’ samples are drawn. (Default value = ‘None’, where ‘ivy.shape(logits)’ samples are drawn)

  • device (Optional[Union[Device, NativeDevice, Container]], default: None) – device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None).

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – output array data type. If dtype is None, the output array data type will be the default floating-point data type. Default None

  • seed (Optional[Union[int, Container]], default: None) – A python integer. Used to create a random seed distribution

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – Drawn samples from the Bernoulli distribution