API Reference
smcjax
Sequential Monte Carlo and particle filtering in JAX.
LiuWestPosterior
Bases: NamedTuple
Full output of a Liu-West particle filter run.
Extends :class:ParticleFilterPosterior with parameter samples.
The Liu-West filter (Liu & West, 2001) jointly estimates latent
states and static parameters using kernel density smoothing.
Attributes:
| Name | Type | Description |
|---|---|---|
marginal_loglik |
Scalar
|
Scalar estimate of
:math: |
filtered_particles |
Float[Array, 'ntime num_particles state_dim']
|
Particle values at each time step,
shape |
filtered_log_weights |
Float[Array, 'ntime num_particles']
|
Unnormalized log weights at each step,
shape |
ancestors |
Int[Array, 'ntime num_particles']
|
Resampled ancestor indices at each time step,
shape |
ess |
Float[Array, ' ntime']
|
Effective sample size at each time step,
shape |
log_evidence_increments |
Float[Array, ' ntime']
|
Per-step log marginal likelihood
increments, shape |
filtered_params |
Float[Array, 'ntime num_particles param_dim']
|
Parameter samples at each time step,
shape |
Source code in smcjax/containers.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
ParticleFilterPosterior
Bases: NamedTuple
Full output of a particle filter run.
Follows the Dynamax PosteriorGSSMFiltered convention of storing
the marginal log-likelihood as a scalar summary alongside the
time-indexed arrays.
Attributes:
| Name | Type | Description |
|---|---|---|
marginal_loglik |
Scalar
|
Scalar estimate of
:math: |
filtered_particles |
Float[Array, 'ntime num_particles state_dim']
|
Particle values at each time step,
shape |
filtered_log_weights |
Float[Array, 'ntime num_particles']
|
Unnormalized log weights at each time step,
shape |
ancestors |
Int[Array, 'ntime num_particles']
|
Resampled ancestor indices at each time step,
shape |
ess |
Float[Array, ' ntime']
|
Effective sample size at each time step,
shape |
log_evidence_increments |
Float[Array, ' ntime']
|
Per-step log marginal likelihood
increments, shape |
Source code in smcjax/containers.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
ParticleFilterResult
Bases: Protocol
Structural type for any particle filter posterior.
Both :class:ParticleFilterPosterior and
:class:LiuWestPosterior satisfy this protocol, so diagnostic
functions can accept either without type errors.
Attributes:
| Name | Type | Description |
|---|---|---|
marginal_loglik |
Scalar
|
Scalar estimate of
:math: |
filtered_particles |
Float[Array, 'ntime num_particles state_dim']
|
Particle values at each time step,
shape |
filtered_log_weights |
Float[Array, 'ntime num_particles']
|
Normalised log weights at each step,
shape |
ancestors |
Int[Array, 'ntime num_particles']
|
Resampled ancestor indices at each time step,
shape |
ess |
Float[Array, ' ntime']
|
Effective sample size at each time step,
shape |
log_evidence_increments |
Float[Array, ' ntime']
|
Per-step log marginal likelihood
increments, shape |
Source code in smcjax/containers.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
ParticleState
Bases: NamedTuple
State of a particle cloud at a single time step.
Attributes:
| Name | Type | Description |
|---|---|---|
particles |
Float[Array, 'num_particles state_dim']
|
Particle values, shape |
log_weights |
Float[Array, ' num_particles']
|
Unnormalized log importance weights,
shape |
log_marginal_likelihood |
Scalar
|
Running log marginal likelihood estimate. |
Source code in smcjax/containers.py
47 48 49 50 51 52 53 54 55 56 57 58 59 | |
auxiliary_filter(key, initial_sampler, transition_sampler, log_observation_fn, log_auxiliary_fn, emissions, num_particles, resampling_fn=systematic, resampling_threshold=0.5)
Run an auxiliary particle filter (Pitt & Shephard, 1999).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNGKeyT
|
JAX PRNG key. |
required |
initial_sampler
|
Callable
|
Function |
required |
transition_sampler
|
Callable
|
Function |
required |
log_observation_fn
|
Callable
|
Function
|
required |
log_auxiliary_fn
|
Callable
|
Function
|
required |
emissions
|
Float[Array, 'ntime emission_dim']
|
Observed emissions, shape |
required |
num_particles
|
int
|
Number of particles :math: |
required |
resampling_fn
|
Callable
|
Resampling algorithm matching the Blackjax
signature |
systematic
|
resampling_threshold
|
float
|
Fraction of |
0.5
|
Returns:
| Type | Description |
|---|---|
ParticleFilterPosterior
|
class: |
ParticleFilterPosterior
|
filtered particles, log weights, ancestor indices, the |
ParticleFilterPosterior
|
marginal log-likelihood estimate, and ESS trace. |
Source code in smcjax/auxiliary.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
bootstrap_filter(key, initial_sampler, transition_sampler, log_observation_fn, emissions, num_particles, resampling_fn=systematic, resampling_threshold=0.5)
Run a bootstrap (SIR) particle filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNGKeyT
|
JAX PRNG key. |
required |
initial_sampler
|
Callable
|
Function |
required |
transition_sampler
|
Callable
|
Function |
required |
log_observation_fn
|
Callable
|
Function
|
required |
emissions
|
Float[Array, 'ntime emission_dim']
|
Observed emissions, shape |
required |
num_particles
|
int
|
Number of particles :math: |
required |
resampling_fn
|
Callable
|
Resampling algorithm matching the Blackjax
signature |
systematic
|
resampling_threshold
|
float
|
Fraction of |
0.5
|
Returns:
| Type | Description |
|---|---|
ParticleFilterPosterior
|
class: |
ParticleFilterPosterior
|
filtered particles, log weights, ancestor indices, the |
ParticleFilterPosterior
|
marginal log-likelihood estimate, and ESS trace. |
Source code in smcjax/bootstrap.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
crps(predictions, observation)
Compute the Continuous Ranked Probability Score.
CRPS is a proper scoring rule for probabilistic forecasts:
.. math::
\text{CRPS} = \mathbb{E}|Y - y|
- \tfrac{1}{2}\,\mathbb{E}|Y - Y'|
where :math:Y, Y' are iid predictive samples and :math:y
is the observation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
Float[Array, ' num_samples']
|
iid samples from the predictive distribution. |
required |
observation
|
Scalar
|
Observed scalar value. |
required |
Returns:
| Type | Description |
|---|---|
Scalar
|
Scalar CRPS (lower is better, zero for perfect prediction). |
Source code in smcjax/diagnostics.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | |
cumulative_log_score(posterior)
Compute the cumulative one-step-ahead predictive log-score.
The log-evidence increments :math:\log p(y_t \mid y_{1:t-1})
are already one-step-ahead predictive log-densities. This
function returns their running sum:
.. math::
S_t = \sum_{s=1}^{t} \log p(y_s \mid y_{1:s-1})
so that :math:S_T equals the total marginal log-likelihood.
Comparing :math:S_t across models gives a time-resolved
predictive comparison that, unlike Bayes factors, is less
sensitive to the prior.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
ParticleFilterResult
|
Particle filter posterior output. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, ' ntime']
|
Cumulative log-scores, shape |
Source code in smcjax/diagnostics.py
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | |
diagnose(posterior, ess_threshold=0.1, diversity_threshold=0.1, pareto_k_threshold=0.7)
Summarise filter health and flag potential problems.
Runs a battery of diagnostics and returns a dictionary with scalar summaries and a list of plain-text warnings. The thresholds are configurable; the defaults flag situations where the particle approximation is likely unreliable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
ParticleFilterResult
|
Particle filter posterior output. |
required |
ess_threshold
|
float
|
Fraction of N below which ESS triggers a warning. |
0.1
|
diversity_threshold
|
float
|
Diversity below which a warning is triggered. |
0.1
|
pareto_k_threshold
|
float
|
Pareto-k above which a warning is triggered. |
0.7
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with keys: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in smcjax/diagnostics.py
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | |
liu_west_filter(key, initial_sampler, transition_sampler, log_observation_fn, log_auxiliary_fn, param_initial_sampler, emissions, num_particles, shrinkage=0.95, resampling_fn=systematic, resampling_threshold=0.5)
Run a Liu-West particle filter (Liu & West, 2001).
Jointly estimates latent states and static parameters using auxiliary particle filtering with kernel density smoothing for parameter propagation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNGKeyT
|
JAX PRNG key. |
required |
initial_sampler
|
Callable
|
Function |
required |
transition_sampler
|
Callable
|
Function |
required |
log_observation_fn
|
Callable
|
Function
|
required |
log_auxiliary_fn
|
Callable
|
Function
|
required |
param_initial_sampler
|
Callable
|
Function
|
required |
emissions
|
Float[Array, 'ntime emission_dim']
|
Observed emissions, shape |
required |
num_particles
|
int
|
Number of particles :math: |
required |
shrinkage
|
float
|
Shrinkage parameter :math: .. warning:: |
0.95
|
resampling_fn
|
Callable
|
Resampling algorithm. Defaults to systematic. |
systematic
|
resampling_threshold
|
float
|
ESS fraction triggering resampling. |
0.5
|
Returns:
| Type | Description |
|---|---|
LiuWestPosterior
|
class: |
LiuWestPosterior
|
filtered particles, parameters, log weights, ancestor indices, |
LiuWestPosterior
|
the marginal log-likelihood estimate, and ESS trace. |
Source code in smcjax/liu_west.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
log_bayes_factor(log_ml_1, log_ml_2)
Compute the log Bayes factor between two models.
.. math::
\log BF_{12} = \log p(y_{1:T} \mid M_1)
- \log p(y_{1:T} \mid M_2)
Positive values favour model 1; negative values favour model 2.
.. warning::
Marginal likelihoods are sensitive to the prior in ways that
the posterior is not. Bayes factors evaluate priors, not
posteriors (Gelman, 2023). With weakly informative priors the
marginal likelihood is dominated by prior tails that have
little effect on posterior inference, so a Bayes factor can
reverse sign under prior changes that leave the posterior
essentially unchanged. Consider complementing Bayes factors
with predictive comparisons (e.g. cumulative log-scores from
:func:`cumulative_log_score` or CRPS from :func:`crps`) and
use :func:`replicated_log_ml` to quantify Monte Carlo
variability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_ml_1
|
Scalar
|
Log marginal likelihood of model 1. |
required |
log_ml_2
|
Scalar
|
Log marginal likelihood of model 2. |
required |
Returns:
| Type | Description |
|---|---|
Scalar
|
Scalar log Bayes factor. |
Source code in smcjax/diagnostics.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
log_ml_increments(posterior)
Extract per-step log marginal likelihood increments.
The marginal log-likelihood can be decomposed as:
.. math::
\log p(y_{1:T}) = \sum_{t=1}^T
\log p(y_t \mid y_{1:t-1})
This function returns the individual increments, which diagnose which observations are hardest for the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
ParticleFilterResult
|
Particle filter posterior output. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, ' ntime']
|
Per-step evidence increments, shape |
Float[Array, ' ntime']
|
to |
Source code in smcjax/diagnostics.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
log_normalize(log_weights)
Normalize log weights and return the log normalizing constant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_weights
|
Float[Array, ' num_particles']
|
Unnormalized log importance weights. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, ' num_particles']
|
A tuple |
Scalar
|
log_normalized has |
tuple[Float[Array, ' num_particles'], Scalar]
|
log_normalizer is |
Source code in smcjax/weights.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
normalize(log_weights)
Exponentiate and normalize log weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_weights
|
Float[Array, ' num_particles']
|
Unnormalized log importance weights. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, ' num_particles']
|
Normalized weights that sum to one. |
Source code in smcjax/weights.py
29 30 31 32 33 34 35 36 37 38 39 40 41 | |
param_weighted_mean(posterior)
Compute the weighted mean of parameter particles at each step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
LiuWestPosterior
|
Liu-West filter posterior output. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, 'ntime param_dim']
|
Weighted parameter means, shape |
Source code in smcjax/diagnostics.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
param_weighted_quantile(posterior, q)
Compute weighted quantiles of parameter particles at each step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
LiuWestPosterior
|
Liu-West filter posterior output. |
required |
q
|
Float[Array, ' num_quantiles']
|
Quantile levels in [0, 1], e.g. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, 'ntime num_quantiles param_dim']
|
Weighted quantiles, shape |
Source code in smcjax/diagnostics.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
pareto_k_diagnostic(posterior)
Compute the Pareto-k diagnostic at each time step.
Fits a generalised Pareto distribution (GPD) to the upper tail of the importance weights using the Zhang and Stephens (2009) profile-likelihood estimator with the weakly informative prior from Vehtari, Simpson, Gelman, Yao, and Gabry (2024).
The shape parameter :math:\hat{k} indicates reliability:
- :math:
\hat{k} < 0.5: good, finite variance of the IS estimate - :math:
0.5 \le \hat{k} < 0.7: marginal - :math:
0.7 \le \hat{k} < 1.0: unreliable (infinite variance) - :math:
\hat{k} \ge 1.0: very unreliable (infinite mean)
The tail size is ceil(min(0.2 * N, 3 * sqrt(N))) order
statistics, matching the conventions of ArviZ and NumPyro.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
ParticleFilterResult
|
Particle filter posterior output. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, ' ntime']
|
Per-step Pareto-k estimates, shape |
Source code in smcjax/diagnostics.py
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
particle_diversity(posterior)
Compute the fraction of unique particles at each time step.
Particle diversity measures path degeneracy: a value near 1 means most particles are distinct, while near 0 means heavy duplication after resampling.
Uses an indicator-based method (not jnp.unique) for JIT
compatibility: counts the fraction of particles that differ from
their predecessor in the sorted order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
ParticleFilterResult
|
Particle filter posterior output. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, ' ntime']
|
Diversity fraction in [0, 1] at each time step, |
Float[Array, ' ntime']
|
shape |
Source code in smcjax/diagnostics.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
posterior_predictive_sample(key, posterior, transition_sampler, emission_sampler, num_samples=None)
Draw one-step-ahead posterior predictive samples.
At each time step :math:t, we:
- Resample particle indices from the normalised weights.
- Propagate each resampled state through
transition_sampler. - Draw an emission from
emission_sampler.
This gives iid samples from the posterior predictive
:math:p(y_{t+1} \mid y_{1:t}), which can be compared with
the actual observation :math:y_{t+1} for posterior predictive
checking (Gelman et al., 2013, ch. 6).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNGKeyT
|
JAX PRNG key. |
required |
posterior
|
ParticleFilterResult
|
Particle filter posterior output. |
required |
transition_sampler
|
Callable
|
Function |
required |
emission_sampler
|
Callable
|
Function |
required |
num_samples
|
int | None
|
Number of predictive draws per time step. Defaults to the number of particles. |
None
|
Returns:
| Type | Description |
|---|---|
Float[Array, 'ntime num_samples emission_dim']
|
Predictive samples, shape |
Float[Array, 'ntime num_samples emission_dim']
|
|
Source code in smcjax/diagnostics.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
replicated_log_ml(key, filter_fn, num_replicates)
Run a particle filter multiple times to assess log-ML variability.
Uses :func:jax.vmap over PRNG keys for efficient parallel
evaluation. The resulting distribution of log-ML estimates
quantifies Monte Carlo uncertainty in the evidence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNGKeyT
|
JAX PRNG key. |
required |
filter_fn
|
Callable[[PRNGKeyT], Scalar]
|
Function |
required |
num_replicates
|
int
|
Number of independent filter runs. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, ' num_replicates']
|
Array of log-ML estimates, shape |
Source code in smcjax/diagnostics.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
tail_ess(posterior, q=0.05)
Compute tail effective sample size at each time step.
Tail-ESS measures how well the weighted particle approximation
represents the tails of the distribution (Vehtari, Gelman,
Simpson, Carpenter, and Burkner, 2020). We compute the ESS
for the indicator function :math:I(w_i \ge w_{(q)}), i.e.
how well the largest weights are distributed.
Specifically, for normalised weights :math:w_i we compute
the ESS of the weights truncated below the :math:(1-q)
quantile:
.. math::
\text{tail-ESS} = \frac{
\bigl(\sum_{i : w_i \ge c} w_i \bigr)^2
}{
\sum_{i : w_i \ge c} w_i^2
}
where :math:c is the :math:(1-q) quantile of the weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
ParticleFilterResult
|
Particle filter posterior output. |
required |
q
|
float
|
Tail probability. Default 0.05, so we examine the top 5% weight mass. |
0.05
|
Returns:
| Type | Description |
|---|---|
Float[Array, ' ntime']
|
Tail-ESS at each time step, shape |
Source code in smcjax/diagnostics.py
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | |
weighted_mean(posterior)
Compute the weighted mean of particles at each time step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
ParticleFilterResult
|
Particle filter posterior output. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, 'ntime state_dim']
|
Weighted means, shape |
Source code in smcjax/diagnostics.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
weighted_quantile(posterior, q)
Compute weighted quantiles of particles at each time step.
Uses a sorted resampling approach for JIT compatibility: sorts particles, computes cumulative weights, and interpolates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
ParticleFilterResult
|
Particle filter posterior output. |
required |
q
|
Float[Array, ' num_quantiles']
|
Quantile levels in [0, 1], e.g. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, 'ntime num_quantiles state_dim']
|
Weighted quantiles, shape |
Source code in smcjax/diagnostics.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
weighted_variance(posterior)
Compute the weighted variance of particles at each time step.
Uses the formula :math:V = \sum_i w_i (x_i - \mu)^2 where
:math:\mu is the weighted mean.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
ParticleFilterResult
|
Particle filter posterior output. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, 'ntime state_dim']
|
Weighted variances, shape |
Source code in smcjax/diagnostics.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |