pangolin.interface.Interface.bernoulli

pangolin.interface.Interface.bernoulli#

Interface.bernoulli(theta)[source]#

Create a Bernoulli distributed RV (Wikipedia).

All arguments must either be scalar or mutually broadcastable according to the broadcasting policy selected when constructing the interface or within an overload block.

Parameters:

theta (RVLike) – probability (between 0 and 1).

Returns:

ir.RV – RV whose operation is pangolin.ir.Bernoulli when all parents are scalar, or one or more nested pangolin.ir.VMap operations around that type when broadcasting is required. The operation has 1 parent.

Return type:

RV

Examples

>>> pi = Interface()
>>> x = pi.bernoulli(0.1)
>>> x
RV(Bernoulli(), RV(Constant(0.1)))
>>> x.shape
()
>>> y = pi.bernoulli([0.1, 0.1])
>>> y
RV(VMap(Bernoulli(), [0], 2), RV(Constant([0.1,0.1])))
>>> y.shape
(2,)