elisa.infer.samplers.ensemble.base#

class EnsembleSamplerState(coords: NDArray[float], random_state: Any)[source]#

Bases: NamedTuple

Ensemble sampler state.

Methods

count(value, /)

Return number of occurrences of value.

index(value[, start, stop])

Return first index of value.

coords: ndarray[tuple[Any, ...], dtype[float]]#

The current positions of the walkers in the parameter space.

random_state: Any#

The state of random number generator.

class EnsembleSampler(numpyro_model: Callable, init_params: dict[str, float] | None = None, ignore_nan: bool = False, seed: int = 42, model_args: tuple = (), model_kwargs: dict | None = None)[source]#

Bases: object

Methods

get_random_state(seed)

Get the random state for the sampler.

get_sampling_fn(chains, warmup, steps, ...)

Generate the sampling function.

run([warmup, steps, chains, thinning, ...])

Run the sampler.

run(warmup: int = 5000, steps: int = 5000, chains: int | None = None, thinning: int = 1, n_parallel: int = 4, tune: bool | None = None, progress: bool = True, states: Sequence[EnsembleSamplerState] | None = None, warmup_kwargs: dict | None = None, sampling_kwargs: dict | None = None) tuple[dict[str, ndarray[tuple[Any, ...], dtype[float]]], tuple[EnsembleSamplerState, ...]][source]#

Run the sampler.

Parameters:
warmupint, optional

The warmup (burn-in) steps. The default is 5000.

stepsint, optional

The sampling steps. The default is 5000.

chainsint, optional

The number of walkers. The default is 4 * ndim.

thinningint

Stores every thinning samples in the chain. When this is set, steps * thinning proposals will be made. The default is 1.

n_parallelint, optional

Number of parallel samplers. The default is 4.

tunebool, optional

Whether to tune the parameters of moves. Defaults to the corresponding sampler’s default.

progressbool, optional

Whether to display a progress bar. The default is True.

statessequence, optional

The initial states of the samplers.

warmup_kwargs: dict, optional

Extra parameters passed to sampler constructor for warm-up phase.

sampling_kwargs: dict | None = None,

Extra parameters passed to sampler constructor for sampling phase.

Returns:
samplesdict

The posterior samples.

statestuple

The states of the samplers.

abstractmethod get_sampling_fn(chains: int, warmup: int, steps: int, thinning: int, tune: bool | None, warmup_kwargs: dict, sampling_kwargs: dict) Callable[[int, EnsembleSamplerState, Queue], tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], EnsembleSamplerState]][source]#

Generate the sampling function.

abstractmethod get_random_state(seed: int) Any[source]#

Get the random state for the sampler.