RandomWalkProposal

class telescopic.kernels.RandomWalkProposal(factor, inverse)

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

Its density is symmetric, so the log acceptance ratio is \(\log\pi(x') - \log\pi(x)\).

Parameters:
factorarray_like, shape (d, d)

\(B\), a factor of the proposal covariance \(BB^\top\), such as its Cholesky factor.

inversearray_like, shape (d, d)

\(B^{-1}\), checked against factor to within rounding; a matrix that is not its inverse raises ValueError.

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.

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.