pangolin.interface.beta_binomial

Contents

pangolin.interface.beta_binomial#

pangolin.interface.beta_binomial(N, alpha, beta)#

Create a BetaBinomial distributed RV (Wikipedia).

This function belongs to the default interface. Thus, all arguments must either be scalar or mutually broadcastable using simple broadcasting, unless changed within an overload() block.

Parameters:
  • N (RVLike) – as in binomial dist.

  • alpha (RVLike) – as in beta dist.

  • beta (RVLike) – as in beta dist.

Returns:

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

Return type:

RV

Examples

>>> import pangolin.interface as pi
>>> x = pi.beta_binomial(0.1, 0.2, 0.4)
>>> x
RV(BetaBinomial(), RV(Constant(0.1)), RV(Constant(0.2)), RV(Constant(0.4)))
>>> x.shape
()
>>> y = pi.beta_binomial([0.1, 0.1], 0.2, 0.4)
>>> y
RV(VMap(BetaBinomial(), [0, None, None], 2), RV(Constant([0.1,0.1])), RV(Constant(0.2)), RV(Constant(0.4)))
>>> y.shape
(2,)

Notes

This follows the (N,alpha,beta) convention of Stan (and Wikipedia). Some other systems (e.g. Numpyro) use alternate variable orderings. This is no problem for you as a user, since pangolin does the re-ordering for you based on the backend. But keep it in mind if translating a model from one system to another.