diagnostics
Post-run diagnostics and resampling for the BlackJAX SMC sampler modes.
Pure functions over a finished SMC state -- no coupling to the sampling loop.
Kept separate so each mode class's get_samples/_get_diagnostics stay
thin composition and the actual math has a name and a docstring of its own.
Functions:
| Name | Description |
|---|---|
kish_ess_history |
Per-iteration Kish effective sample size for tempered modes (at/ft). |
kish_log_z_error |
Delta-method log-evidence standard error for tempered modes (at/ft). |
persistent_ess_history |
Per-iteration persistent-sampling ESS (modes ap/fp). |
persistent_log_z_error |
Delta-method log-evidence standard error for persistent sampling (modes ap/fp). |
resample_persistent_particles |
Draw the posterior sample from a finished persistent-sampling (ap/fp) state. |
kish_ess_history(is_weights_history: np.ndarray) -> np.ndarray
¤
Per-iteration Kish effective sample size for tempered modes (at/ft).
Importance weights are already normalized per iteration, so Kish ESS is
1 / sum(w**2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_weights_history
|
ndarray
|
Per-iteration normalized IS weights,
shape |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
ESS at each iteration, shape |
kish_log_z_error(is_weights_history: np.ndarray) -> float
¤
Delta-method log-evidence standard error for tempered modes (at/ft).
Var(log Z_k) = sum(w**2) - 1/N per step for normalized weights, summed
across steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_weights_history
|
ndarray
|
Per-iteration normalized IS weights,
shape |
required |
Returns:
| Type | Description |
|---|---|
float
|
Standard deviation of the final cumulative |
persistent_ess_history(ps, n_iterations: int) -> np.ndarray
¤
Per-iteration persistent-sampling ESS (modes ap/fp).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ps
|
The algorithm's persistent-sampling state, as in
:func: |
required | |
n_iterations
|
int
|
Number of completed iterations. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
ESS at each iteration |
persistent_log_z_error(ps, n_iterations: int) -> float
¤
Delta-method log-evidence standard error for persistent sampling (modes ap/fp).
At step k, importance weights are exp(delta_beta * logL) over all k
batches of accumulated particles; Var(log Z_k) = Var(w) / (N_eff * E[w]^2),
summed across steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ps
|
The algorithm's persistent-sampling state, as in
:func: |
required | |
n_iterations
|
int
|
Number of completed iterations. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Standard deviation of the final cumulative |
resample_persistent_particles(ps, n_dims: int) -> dict[str, np.ndarray]
¤
Draw the posterior sample from a finished persistent-sampling (ap/fp) state.
Resamples with replacement from all-temperature particles, weighted by the
persistent-sampling weight formula, to a target count approximately equal to
the effective sample size 1 / max(weights).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ps
|
The algorithm's persistent-sampling state ( |
required | |
n_dims
|
int
|
Dimension of the sampling space. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
Dict with keys |
dict[str, ndarray]
|
|