Package: bayesian¶
Nodes for Bayesian inference.
These nodes can be used to specify statistical models and perform Bayesian inference on them using a variety of algorithms. Simply put, the main use case is to quantify and propagate uncertainty through statistical analyses, This yields distributions over resulting quantities which may be further reduced to confidence intervals or other kinds of error bars, or which can also be propagated through most downstream computations. See also the distributions package for the predefined probability distributions. List elsewhere in NeuroPype, observations are typically indexed using the instance axis, features using the feature axis, and so forth, but the nodes can handle any other axes that the input data may contain, and these will propagate through the operations as expected. Note that distributions can be constructed from tensors with extra axes, which is a powerful tool to cause batches of random variables to be drawn from the same distribution; likewise, Random Draw and With Stacked Variables each offer several ways in which extra axes can be introduced, including from template data (via the like= input). Inference results can either be summarized with a statistic axis (indexing, e.g., mean, standard deviation, etc) or with a distribution axis (representing a sample of alternative draws from the posterior distribution). The latter is useful for propagating uncertainty through downstream computations, such as plotting or other post-hoc analyses. The main nodes to use are the Inference nodes, which perform the actual inference and are given a statistical (generative) model. The model itself is made up of Random Draw nodes interspersed with other nodes, and optionally With Stacked Variables, At Subscripts, and (rarely) Log Probability Term. The following node groups exist, which are mainly to configure more finely the behavior of the inference process: - nodes ending in Approx represent types of variational approximations - nodes ending in Sampler represent different sampling algorithms such as NUTS, HMC, and so forth.
Nodes in this package:
-
At Subscripts (Plate)
Apply subsampling (if any) imposed by enclosing With Stacked Variables nodes (plates) to the given data. -
BNAF Approximation (Variational)
A powerful variational approximation of the posterior using block-neural autoregressive flows (BNAF). -
Barker Metropolis-Hastings (Sampler)
The Barker Metropolis-Hastings sampler is a useful fallback if HMC-type samplers (eg NUTS) diverge on some geometry, but will typically be slower, especially on high-dimensional problems. -
Bayesian Deep Net
Instantiate a deep network inside a statistical model. -
Derived Variable (Bayes)
Capture a derived value in a statistical model under a given name. -
Discrete HMC/Gibbs (Sampler)
A hybrid discrete/continuous sampler that uses Gibbs updates to sample from discrete sites along with an underlying Hamiltonian Monte Carlo (HMC)-type sampler for the continuous variables. -
Hamiltonian Monte Carlo (Sampler)
The classic Hamiltonian Monte-Carlo sampler (aka Hybrid Monte Carlo) for use with MCMC inference. -
Add Log-Probability Term (Factor)
Insert an additive term into the log probability of the ambient statistical model. -
Micro-Canonical Langevin Monte Carlo Inference
Apply Bayesian inference given data and a wired-in statistical model, using the Micro-Canonical Langevin Monte Carlo (MCLMC) approach. -
Markov-Chain Monte Carlo Inference (MCMC)
Apply Bayesian inference given data and a wired-in statistical model, using a Markov Chain Monte-Carlo (MCMC) approach. -
Mean-Field Approximation (Variational)
An approximation of the posterior that assumes that all variables are independent of each other and can each be approximated by a univariate Gaussian. -
Mixed Hamiltonian Monte Carlo (Sampler)
The Mixed Hamiltonian Monte-Carlo sampler for use with MCMC inference. -
Multivariate Normal Approximation (Variational)
A multivariate normal variational approximation. -
No U-Turn Sampler (Sampler)
The No U-Turn Sampler (NUTS) for use with MCMC inference. -
Posterior Mode Approximation (Variational)
An approximation of the posterior mode location (MAP), optionally along with a rough estimate of the variance (Laplace). -
Random Draw
Draw a random sample from a distribution, resulting in a random variable. -
Variational Inference
Apply Bayesian inference given data and a wired-in statistical model, using Stochastic Variational Inference (SVI). -
Template Model (Bayes)
Classify data instances using Bayesian Logistic Regression with numpyro. -
With Stacked Variables (Plate)
Context inside of which each Random Draw node behaves like a stack of N independent draws, indexed by a subscript, and where each draw appears stacked along a new axis.