Skip to content

Kernel


class Kernel

Markov kernel.

classDiagram Kernel <|-- LangevinKernel link Kernel "../Kernel/" link LangevinKernel "../LangevinKernel/"

The basic use of a Kernel is to pass it to the move() member function of an Expression to simultaneously update variables and re-evaluate the expression. The Expression typically represents the log-density of a target distribution, and the move represents a proposal, which will be subsequently accepted or rejected (according to e.g. a Metropolis--Hastings acceptance probability).

A Kernel has τςο basic operations:

  • move(): to simulate a new value for a variable given its previous value,
  • logpdf(): to evaluate the log-density of the new value for a variable given its previous value, and

For example, consider a random-walk Metropolis-Hastings algorithm targeting a distribution \pi(\mathrm{d}x). The Kernel object represents a Markov kernel \kappa(\mathrm{d}x' \mid x) ergodic and invariant to \pi(\mathrm{d}x). The object encodes a proposal distribution q(\mathrm{d}x^\prime \mid x), with the member functions move() defining how to simulate from it, and logpdf() how to compute the density q(x^\prime \mid x). In order to accept or reject a proposal it is necessary to compute the Metropolis--Hastings acceptance probability:

\alpha := \min \left(1, \frac{\pi(x^\prime) q(x \mid x^\prime)}{\pi(x) q(x^\prime \mid x)}\right).

One approach is as follows:

  1. An Expression object is used to evaluate \log \pi(x).
  2. Calling move(κ) on the Expression object proposes a new state via subsequent calls to κ.move(...), as well as computing \log \pi(x^\prime).
  3. Calling logratio(κ) on the Expression object computes the log-ratio \log q(x \mid x^\prime) - \log q(x^\prime \mid x), via subsequent calls to logratio(...) on the Kernel object κ.

Member Functions

Name Description
move Propose a transition.
move Propose a transition.
move Propose a transition.
move Propose a transition.
move Propose a transition.
move Propose a transition.
move Propose a transition.
logpdf Observe a transition.
logpdf Observe a transition.
logpdf Observe a transition.
logpdf Observe a transition.
logpdf Observe a transition.
logpdf Observe a transition.
logpdf Observe a transition.

Member Function Details

logpdf

function logpdf(x':Random<Real>, x:Random<Real>) -> Real

Observe a transition.

  • x': Proposed state x^\prime.
  • x: Current state x.

Returns: the log probability density q(x^\prime \mid x).

function logpdf(x':Random<Real[_]>, x:Random<Real[_]>) -> Real

Observe a transition.

  • x': Proposed state x^\prime.
  • x: Current state x.

Returns: the log probability density q(x^\prime \mid x).

function logpdf(x':Random<Real[_,_]>, x:Random<Real[_,_]>) -> Real

Observe a transition.

  • x': Proposed state x^\prime.
  • x: Current state x.

Returns: the log probability density q(x^\prime \mid x).

function logpdf(x':Random<LLT>, x:Random<LLT>) -> Real

Observe a transition.

  • x': Proposed state x^\prime.
  • x: Current state x.

Returns: the log probability density q(x^\prime \mid x).

function logpdf(x':Random<Integer>, x:Random<Integer>) -> Real

Observe a transition.

  • x': Proposed state x^\prime.
  • x: Current state x.

Returns: the log probability mass q(x^\prime \mid x).

function logpdf(x':Random<Integer[_]>, x:Random<Integer[_]>) -> Real

Observe a transition.

  • x': Proposed state x^\prime.
  • x: Current state x.

Returns: the log probability mass q(x^\prime \mid x).

function logpdf(x':Random<Boolean>, x:Random<Boolean>) -> Real

Observe a transition.

  • x': Proposed state x^\prime.
  • x: Current state x.

Returns: the log probability mass.

move

function move(x:Random<Real>) -> Real

Propose a transition.

  • x: Current state.

Returns: Proposed state.

function move(x:Random<Real[_]>) -> Real[_]

Propose a transition.

  • x: Current state.

Returns: Proposed state.

function move(x:Random<Real[_,_]>) -> Real[_,_]

Propose a transition.

  • x: Current state.

Returns: Proposed state.

function move(x:Random<LLT>) -> LLT

Propose a transition.

  • x: Current state.

Returns: Proposed state.

function move(x:Random<Integer>) -> Integer

Propose a transition.

  • x: Current state.

Returns: Proposed state.

function move(x:Random<Integer[_]>) -> Integer[_]

Propose a transition.

  • x: Current state.

Returns: Proposed state.

function move(x:Random<Boolean>) -> Boolean

Propose a transition.

  • x: Current state.

Returns: Proposed state.