Source code for sequince.filtering.kernel
"""Transition kernels for sequential importance sampling."""
from __future__ import annotations
from typing import TYPE_CHECKING, Protocol
from ..typing import Array
if TYPE_CHECKING:
from orng import RandomGenerator
from ..steps.context import StepContext
[docs]
class ImportanceKernel(Protocol):
"""Define a particle transition and its importance-weight correction."""
[docs]
def sample(
self,
particles: Array,
context: StepContext,
rng: RandomGenerator,
) -> Array:
"""Sample the next particle population from the supplied parents."""
[docs]
def log_increment(
self,
previous_particles: Array,
particles: Array,
context: StepContext,
) -> Array | float:
"""Return the transition's importance log-weight increment."""
__all__ = ["ImportanceKernel"]