bellini.api.functional

A high-level interface that provides a backend-agnostic numpy-like API when performing computations on Quantities and Distributions

bellini.api.functional serves as a wrapper for backend tensor-accelerated framework operations. For the most part it doesn’t contain functions itself, and instead wraps whatever function you query from it in a way that you can apply it to things like Quantities or Distributions. Hence, you should import the module instead of attempting to import functions directly from it. A convenient nomenclature, inspired by pytorch, is import bellini.api.functional as F.

For example, say we want to take a log of a Normal Distribution. We can do this using the functional API as such

from bellini.quantity import Quantity as Q
from bellini.distributions import Normal
import bellini.api.functional as F

pre_log_normal = Normal(Q(0), Q(1)) # unitless distribution
log_normal = F.log(pre_log_normal)
# type(log_normal) = TransformedDistribution

Functions

functional_for(f, init, xs[, length])

A wrapper for numpyro's scan primative that also contains a non-numpyro counterpart implementation with similar functionality.