API reference

Each class has a page with its attributes and methods, and the function sample has a page. Each module listed here has a page with the rest of its public names, its functions and, for telescopic.plotting, its three colors, and a table of its classes.

Running

sample

Unbiased estimates of expectations under a target, in one call.

CoupledSampler

Unbiased MCMC with coupled chains: tuning, pilot meeting times and runs.

Results

Result

The output of a run of coupled chains.

Estimate

An unbiased estimate of \(\pi(h)\) with its Monte Carlo error.

Summary

Estimates per parameter and the diagnostics of a run, printable as a table.

SignedMeasure

The signed measures \(\hat\pi_r\) of \(R\) replicates.

Targets and initial distributions

Target

A log-density \(\log\pi\) known up to a constant, with an optional gradient.

telescopic.initial

Initial distributions: where each pair of chains starts.

Normal

Multivariate normal initial distribution \(\mathcal N(\mu, \Sigma)\).

Uniform

Uniform initial distribution on the box [low, high).

Empirical

The uniform distribution over a set of points, such as the last state of an ensemble.

Kernels and couplings

telescopic.kernels

Markov kernels with their couplings.

Kernel

A Markov kernel with its coupling.

State

The states of n chains, batch first: positions, log-densities, gradients, fields.

Draws

Random numbers for a set of chains: row i of every request belongs to chain i.

RandomWalk

Random-walk Metropolis-Hastings with a Gaussian proposal.

MALA

The Metropolis-adjusted Langevin algorithm.

HMC

Hamiltonian Monte Carlo with a random-walk meeting step.

Independence

Independence Metropolis-Hastings.

MultivariateT

Multivariate Student-\(t\) proposal with location mean, scale cov, df.

Gibbs

A Gibbs sampler that draws blocks of coordinates from their full conditionals.

Mixture

A mixture of kernels.

MetropolisHastings

A Metropolis-Hastings kernel from a proposal, coupled by a coupling of that proposal.

Proposal

A Metropolis-Hastings proposal for a batch of chains: its draw, its evaluation and its log acceptance ratio.

RandomWalkProposal

The Gaussian random-walk proposal \(x' = x + Bz\), \(z \sim \mathcal N(0, I)\).

LangevinProposal

The Langevin proposal \(x' = x + B(h/2 + z)\), with \(h = B^\top\nabla\log\pi(x)\).

IndependenceProposal

The independence proposal \(x' \sim q\), whatever the current state.

telescopic.couplings

Couplings of pairs of distributions: the primitives that coupled kernels build on.

Coupling

A coupling of the proposals of two chains under one proposal.

CoupledProposals

The coupled proposals of n pairs of chains, with what each proposal's ratio needs.

Reflection

The reflection-maximal coupling of two Gaussian proposals with a shared covariance.

Maximal

The rejection maximal coupling of two random-walk proposals.

Shared

The coupling of two independence proposals that gives both chains one proposal.

Diagnostics, plots and checks

telescopic.diagnostics

Diagnostics: bounds on the distance to stationarity, tail indices, warnings, gradient checks.

GradientCheck

What the gradient check of a sampler built with a gradient compared.

Issue

A condition that applies to a result and makes it warn.

telescopic.plotting

Plots of results: meeting times, the TV bound and signed histograms (needs matplotlib).

telescopic.testing

Helpers for testing kernels and couplings.

CouplingReport

The checks of check_coupling().

Examples

telescopic.examples

Targets with exact answers, for tests, tutorials and benchmarks.

Example

A target with exact answers.

Building blocks

telescopic.engine

The engine: replicates of coupled chains, run in lockstep lanes with refill.

Replicates

The outputs of a set of replicates, sorted by replicate index, and their run's settings.

Settings

The settings of a run.

Status

The progress of a run, given to its monitor after every iteration.

telescopic.estimators

Estimator weights and the estimators derived from signed measures.

telescopic.tuning

Tuning on pilot runs: adaptive Metropolis chains, and the choice of k.

PilotRun

The second halves of the pilot chains of adaptive_metropolis().

TuningReport

What a tuning pilot found.

Warnings

telescopic.warnings

Warning classes of telescopic.

TelescopicWarning

Base class of the warnings that telescopic emits.

ConvergenceWarning

A result may be unreliable.

InputWarning

An input is legal but questionable, such as an initial draw with zero density.