Skip to content

Gaussian random walk

GaussianRandomWalk ¤

Bases: ProposalBase

Gaussian random walk sampler class.

Methods:

Name Description
__init__

Initialize Gaussian Random Walk sampler.

adapt_step_size

Adapt step size based on acceptance rate.

apply_per_dim_scaling

Multiply step_size element-wise by ratios (returns a new GaussianRandomWalk).

get_effective_dim_profile

Return the current per-dim step size profile normalised to geometric mean 1.

kernel

Random walk gaussian kernel. This is a kernel that only evolve a single

__init__(step_size: Float[Array, ' n_dim'], periodic_mask: Optional[Bool[Array, ' n_dim']] = None, periodic_bounds: Optional[Float[Array, 'n_dim 2']] = None) ¤

Initialize Gaussian Random Walk sampler.

Parameters:

Name Type Description Default
step_size Float[Array, ' n_dim']

Step size for the random walk as a 1D array representing diagonal elements of the proposal covariance matrix.

required
periodic_mask Optional[Bool[Array, ' n_dim']]

Boolean mask indicating which dimensions are periodic. If None, no periodic boundaries are applied.

None
periodic_bounds Optional[Float[Array, 'n_dim 2']]

Array of shape (n_dim, 2) with [lower, upper] bounds for each periodic dimension. Only used where periodic_mask is True. If None, no periodic boundaries are applied.

None

adapt_step_size(acceptance_rate: float, target_rate: float = 0.234) -> Self ¤

Adapt step size based on acceptance rate.

Parameters:

Name Type Description Default
acceptance_rate float

The current acceptance rate.

required
target_rate float

The target acceptance rate (default: 0.234 for RWM).

0.234

Returns:

Name Type Description
GaussianRandomWalk Self

A new instance with updated step_size.

apply_per_dim_scaling(ratios: Float[Array, ' n_dim']) -> Self ¤

Multiply step_size element-wise by ratios (returns a new GaussianRandomWalk).

Parameters:

Name Type Description Default
ratios Float[Array, ' n_dim']

Per-dimension multiplicative scaling factors, shape (n_dim,).

required

Returns:

Name Type Description
GaussianRandomWalk Self

A new instance with updated step_size.

get_effective_dim_profile() -> Float[Array, ' n_dim'] ¤

Return the current per-dim step size profile normalised to geometric mean 1.

kernel(rng_key: Key, position: Float[Array, ' n_dim'], log_prob: Float[Array, 1], logpdf: LogPDF | Callable[[Float[Array, ' n_dim'], PyTree], Float[Array, 1]], data: PyTree) -> tuple[Float[Array, ' n_dim'], Float[Array, 1], Int[Array, 1]] ¤

Random walk gaussian kernel. This is a kernel that only evolve a single chain.

Parameters:

Name Type Description Default
rng_key Key

JAX PRNGKey

required
position Float[Array, n_dim]

current position of the chain

required
log_prob Float[Array, 1]

current log-probability of the chain

required
data PyTree

data to be passed to the logpdf function

required

Returns:

Name Type Description
position Float[Array, n_dim]

new position of the chain

log_prob Float[Array, 1]

new log-probability of the chain

do_accept Int[Array, 1]

whether the new position is accepted