poisson#

ivy.poisson(lam, *, shape=None, device=None, dtype=None, seed=None, fill_value=0, out=None)[source]#

Draws samples from a poisson distribution.

Parameters:
  • lam (Union[float, Array, NativeArray]) – Rate parameter(s) describing the poisson distribution(s) to sample. It must have a shape that is broadcastable to the requested shape.

  • 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(lam)’ 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.

  • fill_value (Optional[Union[int, float]], default: 0) – if lam is negative, fill the output array with this value on that specific dimension.

  • 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 poisson distribution

Examples

>>> lam = [1.0, 2.0, 3.0]
>>> ivy.poisson(lam)
ivy.array([1., 4., 4.])
>>> lam = [1.0, 2.0, 3.0]
>>> ivy.poisson(lam, shape = (2,3))
ivy.array([[0., 2., 2.],
           [1., 2., 3.]])
Array.poisson(self, *, shape=None, device=None, dtype=None, seed=None, fill_value=0, out=None)[source]#
Parameters:
  • self (Array) – Input Array of rate parameter(s). It must have a shape that is broadcastable to the requested shape

  • 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(lam)’ 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

  • fill_value (Optional[Union[float, int]], default: 0) – if lam is negative, fill the output array with this value on that specific dimension.

  • 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 parameterized poisson distribution.

Examples

>>> lam = ivy.array([1.0, 2.0, 3.0])
>>> lam.poisson()
ivy.array([1., 4., 4.])
>>> lam = ivy.array([1.0, 2.0, 3.0])
>>> lam.poisson(shape=(2,3))
ivy.array([[0., 2., 2.],
           [1., 2., 3.]])
Container.poisson(self, /, *, shape=None, device=None, dtype=None, seed=None, fill_value=0, out=None)[source]#

ivy.Container instance method variant of ivy.poisson. This method simply wraps the function, and so the docstring for ivy.poisson also applies to this method with minimal changes.

Parameters:
  • self (Container) – Input container with rate parameter(s) describing the poisson distribution(s) to sample.

  • shape (Optional[Union[Shape, NativeShape, Container]], default: None) – optional container including ints or tuple of ints, Output shape for the arrays in the input container.

  • 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 container array data type. If dtype is None, the output 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.

  • fill_value (Optional[Union[float, int, Container]], default: 0) – if lam is negative, fill the output array with this value on that specific dimension.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including the drawn samples.

Examples

>>> lam = ivy.Container(a=ivy.array([7,6,5]),                                 b=ivy.array([8,9,4]))
>>> shape = ivy.Container(a=(2,3), b=(1,1,3))
>>> lam.poisson(shape=shape)
{
    a: ivy.array([[5, 4, 6],
                  [12, 4, 5]]),
    b: ivy.array([[[8, 13, 3]]])
}