IndependenceProposal

class telescopic.kernels.IndependenceProposal(distribution)

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

The log acceptance ratio is \([\log\pi(x') - \log q(x')] - [\log\pi(x) - \log q(x)]\), with a weight of -inf where \(\pi\) is 0, and a proposal where \(q\) is 0 rejected.

The states carry a cache of \(\log q(x)\), the fields independence.<key>.log_q, shape (n,), and independence.<key>.point, shape (n, d), the point at which it was computed. The key names this proposal object, so that a state stepped by another one, of another distribution, never reads its cache. A value is used only where its point equals the position bit for bit, so that a chain that another kernel moved, or a state without the fields, gets a fresh value. A step and a coupled step evaluate \(\log q\) in one call, at the proposals and at the chains’ states whose value is missing or stale. Where log_density gives a row the same value in any batch, as MultivariateT does, the cache changes no number.

Parameters:
distributionobject

An object with sample(draws) and a normalized log_density(x), such as MultivariateT; one without them raises TypeError. Its mean, if it has one that is not a method, fixes the dimension.

init_extra(state)

The cache of \(\log q\) at the chains’ positions.

Parameters:
stateState

The chains, n of them.

Returns:
dict of str to ndarray

independence.<key>.point, a copy of the positions, and independence.<key>.log_q.

log_alpha(target, current, proposed, forward)

The log acceptance ratios \(\log\pi(x') - \log\pi(x) + \log q(x \mid x') - \log q(x' \mid x)\).

Parameters:
targetTarget

The target that the chains sample.

current, proposedState

The current states and those at the proposals.

forward

What sample() returned with the proposals.

Returns:
ndarray, shape (n,)

NaN, from -inf - -inf, is a rejection.

property ndim

The dimension that the proposal fixes, or None.

Returns:
int or None
sample(target, state, draws)

Draw a proposal \(x' \sim q(\cdot \mid x)\) for each chain.

Parameters:
targetTarget

The target that the chains sample.

stateState

The n chains.

drawsDraws

Random numbers for the n chains.

Returns:
xndarray, shape (n, d)

The proposals.

forward

What log_alpha() needs of the draw, or None.