pangolin.interface.Interface.beta_binomial

pangolin.interface.Interface.beta_binomial#

Interface.beta_binomial(N, alpha, beta)[source]#

Create a BetaBinomial 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:
  • 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

>>> pi = Interface()
>>> 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.