Gaussian random walk
flowMC.resource.kernel.Gaussian_random_walk
¤
GaussianRandomWalk
¤
Bases: ProposalBase
Gaussian random walk sampler class.
ADAPTATION_RATE: float = 0.5
class-attribute
instance-attribute
¤
step_size: Float[Array, ' n_dim'] = step_size
instance-attribute
¤
periodic_mask: Bool[Array, ' n_dim'] = periodic_mask
instance-attribute
¤
periodic_bounds: Float[Array, 'n_dim 2'] = periodic_bounds
instance-attribute
¤
__repr__()
¤
__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
|
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 |
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. |