animate_walkers

flipbook.animate_walkers(model_fn: Callable[[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]], ndarray[tuple[Any, ...], dtype[float64]]], t: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], chain: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | Chain, *, log_prob: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None = None, out: str | Path | None = None, data_t: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None = None, data_y: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None = None, data_err: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None = None, param_transform: Callable[[ndarray[tuple[Any, ...], dtype[float64]]], ndarray[tuple[Any, ...], dtype[float64]]] | None = None, walkers: str | int | Sequence[int] | ndarray[tuple[Any, ...], dtype[integer[Any]]] = 'all', step_slice: slice | tuple[int | None, int | None] | Sequence[int] | ndarray[tuple[Any, ...], dtype[integer[Any]]] | None = None, thin: int = 1, topk_by_logp: int | None = None, vectorized: bool = False, n_jobs: int = 1, chunk_size: int = 32, percentile_bands: Sequence[float] | None = None, per_step_aggregate: str | None = None, color_by: str | None = None, alpha: float = 0.15, max_curves_per_frame: int | None = None, fps: int = 15, dpi: int = 120, writer: str | AbstractMovieWriter | None = None, title: str | Callable[[int], str] | None = None, y_label: str = 'Model', ylim: tuple[float, float] | None = None, progress: bool = False) FuncAnimation[source]

Animate walkers from an MCMC chain for a given model function.

Parameters:
model_fncallable

Callable implementing f(theta, t) -> y.

tarray_like

One-dimensional array of time samples.

chainarray_like or Chain

Either a raw chain array with shape (nsteps, nwalkers, ndim) or a Chain instance.

log_probarray_like, optional

Log-probability values associated with chain. Only required when the chain object does not already include them.

outstr or Path, optional

Output path. When provided, the animation is saved to disk using the requested writer. The animation object is still returned for further manipulation.

data_t, data_y, data_errarray_like, optional

Observational data to overlay. data_err is interpreted as symmetric uncertainties when supplied.

param_transformcallable, optional

Transformation applied to each walker prior to evaluating model_fn.

walkers{‘all’, int, sequence of int}, optional

Walker selection specification.

step_sliceslice, tuple, sequence of int, optional

Steps to include in the animation.

thinint, optional

Frame thinning factor applied after step_slice.

topk_by_logpint, optional

If provided, restricts each frame to the top-K walkers by log probability.

vectorizedbool, optional

Indicates that model_fn supports vectorized evaluation with an (nwalkers, ndim) parameter array.

n_jobsint, optional

Number of threads to use for non-vectorized evaluation.

chunk_sizeint, optional

Number of walkers evaluated together when n_jobs > 1.

percentile_bandssequence of float, optional

Percentile bands to shade in each frame.

per_step_aggregate{‘median’, ‘mean’, None}, optional

Aggregate curve to highlight in each frame.

color_by{‘walker’, ‘logp’, None}, optional

Strategy used to color individual walker curves.

alphafloat, optional

Base transparency applied to walker curves.

max_curves_per_frameint, optional

Upper bound on the number of curves rendered per frame.

fpsint, optional

Target frames per second for the animation.

dpiint, optional

Resolution when writing to disk.

writerstr or matplotlib writer, optional

Animation writer. When None a reasonable default is inferred from the output file extension.

titlestr or callable, optional

Static title string or callable title(step_index) -> str executed per frame.

y_labelstr, optional

Y-axis label for the plot.

ylimtuple, optional

Y-axis limits.

progressbool, optional

Display a progress bar while generating frames. Requires tqdm.

Returns:
matplotlib.animation.FuncAnimation

The generated animation object.