blackjax.ns.base#
Base components for Nested Sampling.
Defines the particle state carrying loglikelihood information, a generic kernel
builder that deletes the lowest-likelihood particles and replaces them with an
inner kernel, and the default deletion strategy selecting the num_delete
particles with the lowest loglikelihoods.
References
Classes#
Functions#
|
Initializes the Nested Sampler state. |
|
Build a generic Nested Sampling kernel. |
|
Identifies particles to be deleted. |
Module Contents#
- class NSState[source]#
State of the Nested Sampler.
At the most basic level, this is just a wrapper around a
StateWithLogLikelihood; richer NS implementations (e.g.AdaptiveNSState) carry extra fields.
- class NSInfo[source]#
Additional information returned at each step of the Nested Sampling algorithm.
- init(positions: blackjax.types.ArrayLikeTree, init_state_fn: Callable, loglikelihood_birth: float = jnp.nan) NSState[source]#
Initializes the Nested Sampler state.
- Parameters:
positions – An initial set of positions (PyTree of arrays) drawn from the prior distribution. The leading dimension of each leaf array must be equal to the number of positions.
init_state_fn – A function that builds the particle state (
StateWithLogLikelihood) from positions;initwraps the result in anNSState. Typically vmapped over the live set.loglikelihood_birth – The initial log-likelihood birth threshold. Defaults to NaN, which implies no initial likelihood constraint beyond the prior.
- Returns:
The initial state of the Nested Sampler.
- Return type:
- build_kernel(delete_fn: Callable, inner_kernel: Callable) Callable[source]#
Build a generic Nested Sampling kernel.
This function creates a kernel for the Nested Sampling algorithm by combining a particle deletion function and an inner kernel for generating new particles.
- Parameters:
delete_fn – A deletion function, typically partially applied with
num_delete, with effective signature(state) -> (dead_idx, target_update_idx). Receives the full NS state (duck-typed) and identifies particles to be deleted and the indices to update.inner_kernel – A kernel function with the signature
(rng_key, state, loglikelihood_0) -> (new_particles, info)that generates replacement particles. Receives the full NS state (duck-typed) and a single PRNG key; returns aStateWithLogLikelihoodwith leading dimensionnum_delete. The number of particles to produce is known at construction time.
- Returns:
A kernel function for Nested Sampling:
(rng_key, state) -> (new_state, ns_info).- Return type:
Callable
- delete_fn(state: NSState, num_delete: int) tuple[blackjax.types.Array, blackjax.types.Array][source]#
Identifies particles to be deleted.
Selects the
num_deleteparticles with the lowest log-likelihoods and marks them as “dead”.- Parameters:
state – The current NS state (duck-typed; must have
.particles.loglikelihood).num_delete – The number of particles to delete and subsequently replace.
- Returns:
A tuple
(dead_idx, target_update_idx)of indices marked for deletionand of slots to overwrite (identical here).