Skip to content

Flowmc

FlowMC-backed sampler for Jim.

Wraps the flowMC Sampler configured with a rational-quadratic spline normalizing flow and a choice of local MCMC kernel, with optional parallel tempering.

FlowMCSampler ¤

Bases: Sampler

flowMC sampler backend.

Wraps the flowMC Sampler with a rational-quadratic spline NF and a configurable local MCMC kernel (MALA, HMC, or GRW) with optional parallel tempering. The flowMC bundle is built lazily inside sample so the PRNG key from Jim is used correctly (no duplication of the seed).

Configured via FlowMCConfig.

Parameters:

Name Type Description Default
n_dims int

Dimension of the sampling space.

required
log_prior_fn Callable

Log-prior callable (arr,) -> float.

required
log_likelihood_fn Callable

Log-likelihood callable (arr,) -> float.

required
log_posterior_fn Callable

Log-posterior callable (arr,) -> float.

required
config Optional[FlowMCConfig]

Optional FlowMCConfig; defaults to all-default values.

None
periodic Optional[dict[int, tuple[float, float]]]

Optional periodic-parameter spec in index space, dict[int, (lo, hi)] where the key is the dimension index. None means no periodic parameters. Provided by Jim after resolving parameter names to indices.

None

Methods:

Name Description
get_samples

Return all production samples with their log-likelihoods.

Attributes:

Name Type Description
strategy_order list[str]

Ordered list of flowMC strategies.

strategy_order: list[str] property ¤

Ordered list of flowMC strategies.

get_samples() -> dict[str, np.ndarray] ¤

Return all production samples with their log-likelihoods.

Production samples are flat arrays in sampling space, shape (N, n_dims) where N = n_chains * n_production_loops * n_total_steps. Log-likelihoods are recovered from the stored log-posterior values as log_likelihood = log_posterior - log_prior, avoiding a second evaluation of the likelihood function.

Returns:

Type Description
dict[str, ndarray]

Dict with keys "samples" (shape (N, n_dims)) and

dict[str, ndarray]

"log_likelihood" (shape (N,)).