Smoothers

DelayedStateOutput = tuple[int, Any] module-attribute

FBFBMEMQKFSmoother = ForwardBackwardForwardBackwardMEMQKFSmoother module-attribute

FixedIntervalMemQkfSmoother = FixedIntervalMEMQKFSmoother module-attribute

FixedLagFreeMEMQKFSmoother = FixedLagMEMQKFSmoother module-attribute

FixedLagMemQkfSmoother = FixedLagMEMQKFSmoother module-attribute

FLMEMQKFSmoother = FixedLagMEMQKFSmoother module-attribute

ForwardBackwardMEMQKFSmoother = ForwardBackwardForwardBackwardMEMQKFSmoother module-attribute

FullIntervalMEMQKFSmoother = FixedIntervalMEMQKFSmoother module-attribute

FixedLagFactorizedGIWRMSmoother = FixedLagFactorizedGIWRandomMatrixSmoother module-attribute

FixedLagRMTSmoother = FixedLagRandomMatrixSmoother module-attribute

FLGIWRMSmoother = FixedLagFactorizedGIWRandomMatrixSmoother module-attribute

FLRMSmoother = FixedLagRandomMatrixSmoother module-attribute

FixedLagVLMEMQKFSmoother = FixedLagVelocityLockedMEMQKFSmoother module-attribute

FLVLMEMQKFSmoother = FixedLagVelocityLockedMEMQKFSmoother module-attribute

MEMRBPF_FFBSiSmoother = MEMRBPFFFBSiSmoother module-attribute

RBFFBSiSmoother = MEMRBPFFFBSiSmoother module-attribute

RTSSmoother = RauchTungStriebelSmoother module-attribute

SO3CMSmoother = SO3ChordalMeanSmoother module-attribute

SO3TSGSmoother = SO3TangentSavitzkyGolaySmoother module-attribute

URTSSmoother = UnscentedRauchTungStriebelSmoother module-attribute

__all__ = ['AbstractSmoother', 'DelayedStateOutput', 'DelayedStateOutputMixin', 'FBFBMEMQKFSmoother', 'FixedIntervalMEMQKFSmoother', 'FixedIntervalMemQkfSmoother', 'FixedLagFreeMEMQKFSmoother', 'FixedLagMEMQKFSmoother', 'FixedLagMemQkfSmoother', 'FLMEMQKFSmoother', 'FullIntervalMEMQKFSmoother', 'ForwardBackwardForwardBackwardMEMQKFSmoother', 'ForwardBackwardMEMQKFSmoother', 'MEMQKFSmootherGain', 'MEMQKFTrackerState', 'FactorizedGIWRandomMatrixTrackerState', 'FixedLagFactorizedGIWRMSmoother', 'FixedLagFactorizedGIWRandomMatrixSmoother', 'FixedLagRandomMatrixSmoother', 'FixedLagRMTSmoother', 'FLGIWRMSmoother', 'FLRMSmoother', 'RandomMatrixTrackerState', 'FixedLagVelocityLockedMEMQKFSmoother', 'FixedLagVLMEMQKFSmoother', 'FLVLMEMQKFSmoother', 'VelocityLockedMEMQKFSmootherGain', 'VelocityLockedMEMQKFTrackerState', 'MEMRBPFForwardRecord', 'MEMRBPF_FFBSiSmoother', 'MEMRBPFFFBSiSmoother', 'RBFFBSiResult', 'RBFFBSiSmoother', 'RauchTungStriebelSmoother', 'RTSSmoother', 'RecordSmootherConfig', 'fixed_lag_smooth_records', 'rts_smooth_records', 'smooth_records', 'SlidingWindowManifoldMeanSmoother', 'SO3ChordalMeanSmoother', 'SO3CMSmoother', 'SO3TangentSavitzkyGolaySmoother', 'SO3TSGSmoother', 'UnscentedRauchTungStriebelSmoother', 'URTSSmoother'] module-attribute

AbstractSmoother

Bases: ABC

Abstract base class for all smoothers.

smooth(*args, **kwargs) abstractmethod

Smooth a sequence of states produced by a forward pass.

DelayedStateOutputMixin

Mixin implementing the delayed-output queue used by fixed-lag smoothers.

Subclasses should call :meth:_initialize_delayed_state_outputs during initialization. The mixin also initializes lazily, which keeps it usable in lightweight test doubles and with classes restored through __new__.

The public convention is intentionally simple: ready outputs are returned as (step_index, state) tuples. The state object can be a backend array, NumPy array, dataclass, tracker state, or any other payload selected by the concrete smoother.

outputs_delayed_states = True class-attribute instance-attribute

last_emitted_step property

Index of the latest queued or finalized delayed output.

pop_ready_states()

Return and clear newly available delayed outputs.

FixedIntervalMEMQKFSmoother

Bases: FixedLagMEMQKFSmoother

Full fixed-interval RTS smoother for MEMQKFTracker posterior sequences.

__init__(shape_smoothing='rts')

smooth(filtered_states, predicted_states=None, system_matrices=None, shape_system_matrices=None, lag=None)

Return full-interval smoothed MEM-QKF tracker states.

FixedLagMEMQKFSmoother

Bases: AbstractSmoother

Fixed-lag RTS smoother for MEMQKFTracker posterior sequences.

The kinematic state is smoothed with the standard finite-window RTS recursion. The MEM-QKF shape state [orientation, semi_axis_1, semi_axis_2] can either be smoothed with a separate RTS recursion or be passed through unchanged. Orientation residuals are treated as axial, pi-periodic ellipse-orientation differences.

lag = lag instance-attribute

shape_smoothing = shape_smoothing instance-attribute

__init__(lag=1, shape_smoothing='rts')

smooth(filtered_states, predicted_states=None, system_matrices=None, shape_system_matrices=None, lag=None)

Return fixed-lag smoothed MEM-QKF tracker states.

append(filtered_state, predicted_state=None, system_matrix=None, shape_system_matrix=None)

Append a filtered state and emit the oldest fixed-lag state if ready.

flush()

Return all still-buffered states with truncated look-ahead windows.

ForwardBackwardForwardBackwardMEMQKFSmoother

Bases: FixedLagMEMQKFSmoother

Full-interval MEM-QKF smoother with conditional alternating passes.

The pass order is forward-filtered input, backward RTS kinematics, forward MEM-QKF shape updates conditioned on the smoothed kinematic centers, and a final backward RTS pass for orientation and semi-axis lengths. Setting n_iterations > 1 alternates this with kinematic re-filtering conditioned on the improved shape trajectory before smoothing kinematics and shape again.

If no initial shape prior is supplied, the first scan's original filtered shape posterior is kept as the conditional forward pass initial state to avoid double-counting the first measurement set. Supplying initial_shape_state and initial_shape_covariance lets the smoother reprocess every scan. Kinematic re-filtering follows the same convention unless initial_kinematic_state and initial_kinematic_covariance are supplied to :meth:smooth.

n_iterations = n_iterations instance-attribute

include_kinematic_covariance = _coerce_bool_flag(include_kinematic_covariance, 'include_kinematic_covariance') instance-attribute

include_single_measurement_axis_covariance = _coerce_bool_flag(include_single_measurement_axis_covariance, 'include_single_measurement_axis_covariance') instance-attribute

__init__(shape_smoothing='rts', n_iterations=1, include_kinematic_covariance=True, include_single_measurement_axis_covariance=True)

smooth(filtered_states, predicted_states=None, measurements=None, system_matrices=None, shape_system_matrices=None, meas_noise_covs=None, measurement_matrices=None, multiplicative_noise_covs=None, kinematic_process_noises=None, shape_process_noises=None, initial_kinematic_state=None, initial_kinematic_covariance=None, initial_shape_state=None, initial_shape_covariance=None, n_iterations=None, lag=None)

Return full-interval smoothed states after conditional shape re-forwarding.

MEMQKFSmootherGain dataclass

Smoother gains for one MEM-QKF backward recursion step.

kinematic instance-attribute

shape = None class-attribute instance-attribute

__init__(kinematic, shape=None)

MEMQKFTrackerState dataclass

Detached snapshot of a :class:MEMQKFTracker state.

kinematic_state instance-attribute

covariance instance-attribute

shape_state instance-attribute

shape_covariance instance-attribute

measurement_matrix = None class-attribute instance-attribute

multiplicative_noise_cov = None class-attribute instance-attribute

covariance_regularization = 0.0 class-attribute instance-attribute

default_meas_noise_cov = None class-attribute instance-attribute

update_mode = 'sequential' class-attribute instance-attribute

minimum_axis_length = 1e-09 class-attribute instance-attribute

minimum_covariance_eigenvalue = 0.0 class-attribute instance-attribute

from_tracker(tracker) classmethod

Create a detached snapshot from tracker.

copy()

Return a detached copy of this state.

to_tracker()

Convert this snapshot back to a mutable tracker instance.

__init__(kinematic_state, covariance, shape_state, shape_covariance, measurement_matrix=None, multiplicative_noise_cov=None, covariance_regularization=0.0, default_meas_noise_cov=None, update_mode='sequential', minimum_axis_length=1e-09, minimum_covariance_eigenvalue=0.0)

FactorizedGIWRandomMatrixTrackerState dataclass

Detached snapshot of a factorized GIW random-matrix tracker state.

kinematic_state instance-attribute

covariance instance-attribute

extent_dof instance-attribute

extent_scale instance-attribute

kinematic_state_to_pos_matrix = None class-attribute instance-attribute

extent_transition_dof = None class-attribute instance-attribute

extent_transition_matrix = None class-attribute instance-attribute

measurement_spread_factor = 1.0 class-attribute instance-attribute

minimum_extent_eigenvalue = 1e-12 class-attribute instance-attribute

extent_dimension property

extent_mean_denominator property

extent property

from_tracker(tracker) classmethod

Create a detached state snapshot from tracker.

copy()

Return a detached copy of this state.

to_tracker()

Convert this snapshot back to a mutable tracker instance.

__init__(kinematic_state, covariance, extent_dof, extent_scale, kinematic_state_to_pos_matrix=None, extent_transition_dof=None, extent_transition_matrix=None, measurement_spread_factor=1.0, minimum_extent_eigenvalue=1e-12)

FixedLagFactorizedGIWRandomMatrixSmoother

Bases: AbstractSmoother

Fixed-lag smoother for factorized GIW random-matrix tracker states.

This class applies the factorized Gaussian inverse-Wishart backward recursion of Granstrom and Bramstang, IEEE TSP 2019, Table VII. Unlike :class:FixedLagRandomMatrixSmoother, it keeps the inverse-Wishart parameters v and V explicit and therefore implements the paper's finite-transition-dof correction terms directly.

lag = lag instance-attribute

extent_smoothing = extent_smoothing instance-attribute

extent_transition_dof = float(extent_transition_dof) instance-attribute

minimum_extent_weight = float(minimum_extent_weight) instance-attribute

minimum_extent_eigenvalue = float(minimum_extent_eigenvalue) instance-attribute

__init__(lag=1, extent_smoothing='granstrom', extent_transition_dof=100.0, minimum_extent_weight=1e-12, minimum_extent_eigenvalue=1e-12)

smooth(filtered_states, predicted_states=None, system_matrices=None, extent_transition_matrices=None, lag=None)

Return fixed-lag smoothed factorized GIW tracker states.

append(filtered_state, predicted_state=None, system_matrix=None, extent_transition_matrix=None)

Append a filtered state and emit the oldest fixed-lag state if ready.

flush()

Return all still-buffered states with truncated look-ahead windows.

FixedLagRandomMatrixSmoother

Bases: AbstractSmoother

Fixed-lag smoother for RandomMatrixTracker posterior sequences.

The kinematic state is smoothed with a finite-window RTS recursion. The default random-matrix extent smoother follows the constant-extent-dynamics factorized GIW backward recursion of Granstrom and Bramstang, "Bayesian Smoothing for the Extended Object Random Matrix Model", IEEE TSP 2019, Table VII. Since :class:RandomMatrixTrackerState stores only the extent mean and an effective information scalar alpha, the implementation reconstructs the inverse-Wishart natural parameter as V = alpha * X and treats alpha as v - 2d - 2. Set extent_smoothing='information' for the earlier SPD-preserving alpha-weighted average, or extent_smoothing='none' to smooth only the kinematic component. Provide extent_transition_dof to include the paper's finite-transition-dof correction terms; the default omits those corrections.

lag = lag instance-attribute

extent_smoothing = extent_smoothing instance-attribute

extent_smoothing_factor = float(extent_smoothing_factor) instance-attribute

minimum_extent_weight = float(minimum_extent_weight) instance-attribute

extent_transition_dof = None if extent_transition_dof is None else float(extent_transition_dof) instance-attribute

__init__(lag=1, extent_smoothing='granstrom', extent_smoothing_factor=1.0, minimum_extent_weight=1e-12, extent_transition_dof=None)

smooth(filtered_states, predicted_states=None, system_matrices=None, lag=None)

Return fixed-lag smoothed random-matrix tracker states.

append(filtered_state, predicted_state=None, system_matrix=None)

Append a filtered state and emit the oldest fixed-lag state if ready.

flush()

Return all still-buffered states with truncated look-ahead windows.

RandomMatrixTrackerState dataclass

Detached snapshot of a :class:RandomMatrixTracker state.

kinematic_state instance-attribute

covariance instance-attribute

extent instance-attribute

alpha = 0.0 class-attribute instance-attribute

kinematic_state_to_pos_matrix = None class-attribute instance-attribute

from_tracker(tracker) classmethod

Create a detached state snapshot from tracker.

copy()

Return a detached copy of this state.

to_tracker()

Convert this snapshot back to a mutable tracker instance.

__init__(kinematic_state, covariance, extent, alpha=0.0, kinematic_state_to_pos_matrix=None)

FixedLagVelocityLockedMEMQKFSmoother

Bases: AbstractSmoother

Fixed-lag smoother for VelocityLockedMEMQKFTracker posterior sequences.

Kinematics are smoothed by a finite-window RTS recursion. The MEM-QKF shape state can either be passed through unchanged or smoothed by a separate RTS recursion in [orientation, semi_axis_1, semi_axis_2] space. Every output state is then projected back to the decoupled MEM-QKF covariance convention, and moving states are relocked to the smoothed kinematic velocity.

lag = lag instance-attribute

shape_smoothing = shape_smoothing instance-attribute

__init__(lag=1, shape_smoothing='rts')

smooth(filtered_states, predicted_states=None, system_matrices=None, shape_system_matrices=None, lag=None)

Return fixed-lag smoothed VL-MEM-QKF tracker states.

append(filtered_state, predicted_state=None, system_matrix=None, shape_system_matrix=None)

Append a filtered state and emit the oldest fixed-lag state if ready.

flush()

Return all still-buffered states with truncated look-ahead windows.

VelocityLockedMEMQKFSmootherGain dataclass

Smoother gains for one VL-MEM-QKF backward recursion step.

kinematic instance-attribute

shape = None class-attribute instance-attribute

__init__(kinematic, shape=None)

VelocityLockedMEMQKFTrackerState dataclass

Detached snapshot of a :class:VelocityLockedMEMQKFTracker state.

kinematic_state instance-attribute

covariance instance-attribute

shape_state instance-attribute

shape_covariance instance-attribute

measurement_matrix = None class-attribute instance-attribute

multiplicative_noise_cov = None class-attribute instance-attribute

covariance_regularization = 0.0 class-attribute instance-attribute

default_meas_noise_cov = None class-attribute instance-attribute

update_mode = 'sequential' class-attribute instance-attribute

minimum_axis_length = 1e-09 class-attribute instance-attribute

minimum_covariance_eigenvalue = 0.0 class-attribute instance-attribute

velocity_indices = (2, 3) class-attribute instance-attribute

speed_threshold = 1e-09 class-attribute instance-attribute

orientation_offset = 0.0 class-attribute instance-attribute

sideslip_variance = 0.0 class-attribute instance-attribute

minimum_orientation_variance = 1e-12 class-attribute instance-attribute

from_tracker(tracker) classmethod

Create a detached snapshot from tracker.

copy()

Return a detached copy of this state.

to_tracker()

Convert this snapshot back to a mutable tracker instance.

__init__(kinematic_state, covariance, shape_state, shape_covariance, measurement_matrix=None, multiplicative_noise_cov=None, covariance_regularization=0.0, default_meas_noise_cov=None, update_mode='sequential', minimum_axis_length=1e-09, minimum_covariance_eigenvalue=0.0, velocity_indices=(2, 3), speed_threshold=1e-09, orientation_offset=0.0, sideslip_variance=0.0, minimum_orientation_variance=1e-12)

MEMRBPFFFBSiSmoother

Bases: AbstractSmoother

Fixed-interval Rao-Blackwellized FFBSi smoother for MEM-RBPF records.

The MEM-RBPF representation consists of one global kinematic Gaussian and a weighted orientation-particle approximation with conditional Gaussian semi-axis states. This smoother runs RTS smoothing for the global kinematic Gaussian and backward-simulates orientation/semi-axis trajectories.

n_trajectories = None if n_trajectories is None else int(n_trajectories) instance-attribute

sample_axis = _coerce_bool_flag(sample_axis, 'sample_axis') instance-attribute

angle_wrap_terms = int(angle_wrap_terms) instance-attribute

axis_floor = float(axis_floor) instance-attribute

__init__(n_trajectories=None, sample_axis=True, angle_wrap_terms=2, axis_floor=1e-09)

smooth(records, rng=None, *, n_trajectories=None, sample_axis=None, angle_wrap_terms=None, full_axis_lengths=True)

Run fixed-interval RB-FFBSi over explicit MEM-RBPF records.

MEMRBPFForwardRecord dataclass

Weighted filtering approximation at one MEM-RBPF measurement time.

kinematic_state instance-attribute

covariance instance-attribute

theta instance-attribute

axis_mean instance-attribute

axis_covariance instance-attribute

weights instance-attribute

system_matrix = None class-attribute instance-attribute

sys_noise = None class-attribute instance-attribute

axis_system_matrix = None class-attribute instance-attribute

axis_sys_noise = None class-attribute instance-attribute

orientation_process_variance = 0.0 class-attribute instance-attribute

n_particles property

state_dim property

axis_dim property

from_tracker(tracker, *, use_latest=True) classmethod

Create a record from a :class:MEMRBPFTracker instance.

Newer trackers may expose get_filtering_state to return a stored post-update/pre-resampling snapshot. For older trackers this falls back to the current tracker arrays.

from_mapping(mapping) classmethod

Create a record from a mapping of MEM-RBPF arrays.

copy()

Return a detached copy of this record.

__init__(kinematic_state, covariance, theta, axis_mean, axis_covariance, weights, system_matrix=None, sys_noise=None, axis_system_matrix=None, axis_sys_noise=None, orientation_process_variance=0.0)

RBFFBSiResult dataclass

Output of :class:MEMRBPFFFBSiSmoother.

states instance-attribute

kinematic_mean instance-attribute

kinematic_covariance instance-attribute

theta_samples instance-attribute

axis_samples instance-attribute

index_samples instance-attribute

sample_states instance-attribute

kinematic_cov property

Backward-compatible alias for kinematic_covariance.

__init__(states, kinematic_mean, kinematic_covariance, theta_samples, axis_samples, index_samples, sample_states)

RauchTungStriebelSmoother

Bases: AbstractSmoother

Rauch--Tung--Striebel smoother for linear Gaussian models.

This class intentionally does not depend on pyrecest.filters.KalmanFilter. The current filter classes do not retain the full forward-pass history that an RTS smoother requires, so this implementation provides its own forward pass for sequences of linear Gaussian models.

The accepted model inputs can each either be a single matrix/vector reused for the whole sequence or a sequence with one entry per time step.

Parameters

initial_state Initial prior state as GaussianDistribution or (mean, covariance). measurements Sequence of measurements. A one-dimensional array is interpreted as a sequence of scalar measurements. For vector measurements, pass a list/tuple of one-dimensional arrays or a two-dimensional array of shape (T, dim_z). measurement_matrices Measurement matrix H or sequence H_t. Defaults to identity. meas_noise_covariances Measurement noise covariance R or sequence R_t. system_matrices Transition matrix F or sequence F_t used between consecutive time steps. Defaults to identity. sys_noise_covariances Process noise covariance Q or sequence Q_t. Defaults to zero. sys_inputs Optional control/input vector u or sequence u_t added in the prediction step. Defaults to zero.

filter(initial_state, measurements, measurement_matrices=None, meas_noise_covariances=None, system_matrices=None, sys_noise_covariances=None, sys_inputs=None)

Run the forward Kalman filtering pass for a sequence.

Returns

filtered_states List of posterior states x_{t|t}. predicted_states List of one-step predictions x_{t+1|t}. Its length is one less than the number of measurements.

smooth(filtered_states, predicted_states, system_matrices=None)

Run the RTS backward pass.

Parameters

filtered_states Sequence of posterior states x_{t|t}. predicted_states Sequence of one-step predictions x_{t+1|t}. system_matrices Transition matrix F or sequence F_t used in the forward pass.

Returns

smoothed_states List of smoothed posterior states x_{t|T}. smoother_gains List of RTS smoother gains, one per backward recursion step.

filter_and_smooth(initial_state, measurements, measurement_matrices=None, meas_noise_covariances=None, system_matrices=None, sys_noise_covariances=None, sys_inputs=None)

Run a full forward-backward pass for a linear Gaussian sequence.

RecordSmootherConfig dataclass

Configuration for :func:smooth_records.

Parameters

method: "rts" runs a full Rauch--Tung--Striebel backward pass. "fixed-lag" applies the same backward recursion only over future records within lag seconds. "none" returns copied records. lag: Finite nonnegative fixed-lag horizon in seconds. Required for "fixed-lag". time_key, state_key, covariance_key: Keys used to extract timestamp, filtered state, and filtered covariance. output_state_key, output_covariance_key: Keys used for the smoothed posterior in returned records. filtered_state_key, filtered_covariance_key: Keys used to preserve the original filtered posterior in returned records. metadata: Extra key/value pairs appended to every returned record.

method = 'fixed-lag' class-attribute instance-attribute

lag = None class-attribute instance-attribute

time_key = 'time_s' class-attribute instance-attribute

state_key = 'state' class-attribute instance-attribute

covariance_key = 'covariance' class-attribute instance-attribute

output_state_key = 'state' class-attribute instance-attribute

output_covariance_key = 'covariance' class-attribute instance-attribute

filtered_state_key = 'filtered_state' class-attribute instance-attribute

filtered_covariance_key = 'filtered_covariance' class-attribute instance-attribute

metadata = None class-attribute instance-attribute

__init__(method='fixed-lag', lag=None, time_key='time_s', state_key='state', covariance_key='covariance', output_state_key='state', output_covariance_key='covariance', filtered_state_key='filtered_state', filtered_covariance_key='filtered_covariance', metadata=None)

SlidingWindowManifoldMeanSmoother

Bases: AbstractSmoother

Smooth state estimates by replacing each entry with a local manifold mean.

The smoother extracts a representative point from each input state. For PyRecEst distributions this is state.mean(); raw arrays are used directly. Each sliding window is then represented as a Dirac distribution on the same manifold, and the Dirac distribution's mean() defines the smoothed value.

Parameters

window_size Number of sequence entries considered for each smoothed state. Edge windows are truncated to the available samples. dirac_distribution_factory Optional callable factory(points, weights) used to construct the window Dirac distribution. This is useful for raw samples on non-linear manifolds. If omitted, the smoother infers a factory from distribution inputs and falls back to a Euclidean Dirac distribution for raw arrays. window_weights Optional non-negative weights with length window_size. Truncated edge windows use the corresponding weight slice and are renormalized by the Dirac distribution. alignment "center" uses past and future estimates around each state, "trailing" uses the current and previous estimates, and "leading" uses the current and following estimates.

window_size = window_size instance-attribute

dirac_distribution_factory = dirac_distribution_factory instance-attribute

alignment = alignment instance-attribute

window_weights = None instance-attribute

__init__(window_size=3, dirac_distribution_factory=None, window_weights=None, alignment='center')

smooth(states)

Return smoothed manifold mean values for a sequence of states.

SO3ChordalMeanSmoother

Bases: AbstractSmoother

Smooth SO(3) rotation sequences with local weighted chordal means.

Rotations are represented as 3-by-3 rotation matrices. The chordal mean is computed by averaging rotation matrices in the ambient Euclidean space and projecting the result back onto SO(3) with the orthogonal Procrustes solution.

Parameters

window_size Number of neighboring rotations used per local mean. The window is centered as far as possible around each time index and clipped at the sequence boundaries. kernel_weights Optional nonnegative weights for positions inside the local window. If provided, its length must match window_size.

window_size = self._validate_window_size(window_size) instance-attribute

kernel_weights = self._normalize_weight_vector(kernel_weights, self.window_size, 'kernel_weights', normalize=False) instance-attribute

__init__(window_size=3, kernel_weights=None)

project_to_so3(matrix) staticmethod

Project a 3-by-3 matrix to the closest SO(3) rotation matrix.

chordal_distance(rotation_a, rotation_b) staticmethod

Return the Frobenius chordal distance between two SO(3) rotations.

chordal_mean(rotations, weights=None) classmethod

Compute the weighted chordal mean of one or more SO(3) rotations.

smooth(rotations, weights=None, window_size=None)

Smooth a rotation sequence with local chordal means.

Parameters

rotations Rotation matrix sequence as a Python sequence, (n, 3, 3) array, or (3, 3, n) array. weights Optional nonnegative reliability weights, one per input rotation. window_size Optional per-call override for the number of rotations in each local mean. Kernel weights from construction are only used when this is not overridden.

Returns

list Smoothed SO(3) rotations, one per input rotation.

SO3TangentSavitzkyGolaySmoother

Bases: AbstractSmoother

Smooth SO(3) sequences with local tangent-space polynomial fits.

This smoother is a manifold-valued Savitzky-Golay-style baseline. For each time index, visible rotations in a centered local window are mapped to the tangent space of the nearest visible rotation. A weighted local polynomial is fitted against time offsets, the intercept is evaluated at the current time, and the result is mapped back to SO(3).

Rotations are represented as 3-by-3 rotation matrices. The optional mask marks reliable observations; masked samples are skipped rather than treated as identity rotations. smooth_product applies the same per-component smoother to product states with shape (n, k, 3, 3).

window_size = self._validate_window_size(window_size) instance-attribute

polynomial_degree = self._validate_polynomial_degree(polynomial_degree) instance-attribute

__init__(window_size=7, polynomial_degree=2)

smooth(rotations, mask=None, window_size=None, polynomial_degree=None)

Smooth a sequence of SO(3) rotation matrices.

Parameters

rotations Rotation matrix sequence as a Python sequence, (n, 3, 3) array, or (3, 3, n) array. mask Optional Boolean reliability mask with one entry per rotation. Masked-out rotations are ignored in local polynomial fits. window_size Optional per-call override for the odd local window size. polynomial_degree Optional per-call override for the polynomial degree.

Returns

list Smoothed SO(3) rotations, one per input rotation.

smooth_product(rotations, mask=None, window_size=None, polynomial_degree=None)

Smooth product-state rotations with shape (n, k, 3, 3).

The optional mask must have shape (n, k) and is applied independently to each SO(3) component.

UnscentedRauchTungStriebelSmoother

Bases: AbstractSmoother

Unscented fixed-interval smoother for nonlinear Gaussian state-space models.

This implements the unscented Rauch--Tung--Striebel (URTS) smoother for Euclidean state spaces. It mirrors the current :class:UnscentedKalmanFilter scope in PyRecEst and therefore only supports the NumPy backend.

The smoother provides a complete forward pass (filter) and the backward pass (smooth). For the nonlinear case the smoother gain depends on the predicted cross-covariance between x_t and x_{t+1}, so the forward pass stores those cross-covariances explicitly.

Parameters

points Optional sigma-point object compatible with MerweScaledSigmaPoints. If omitted, standard Merwe scaled sigma points are used. alpha, beta, kappa Default sigma-point parameters used when points is omitted.

points = points instance-attribute

alpha = alpha instance-attribute

beta = beta instance-attribute

kappa = kappa instance-attribute

__init__(points=None, alpha=0.001, beta=2.0, kappa=0.0)

filter(initial_state, measurements, measurement_functions=None, meas_noise_covariances=None, transition_functions=None, sys_noise_covariances=None, time_steps=None)

Run the forward unscented filtering pass for a full sequence.

Returns

filtered_states Posterior states x_{t|t}. predicted_states One-step predictions x_{t+1|t} with length T - 1. predicted_cross_covariances Cross-covariances Cov[x_t, x_{t+1}] needed by the URTS backward pass.

smooth(filtered_states, predicted_states, predicted_cross_covariances)

Run the unscented RTS backward pass.

smooth_from_filtered(filtered_states, transition_functions=None, sys_noise_covariances=None, time_steps=None)

Smooth from filtered states by recomputing nonlinear predictions.

filter_and_smooth(initial_state, measurements, measurement_functions=None, meas_noise_covariances=None, transition_functions=None, sys_noise_covariances=None, time_steps=None)

Convenience wrapper that runs both the forward and backward passes.

fixed_lag_smooth_records(records, *, transition_model, process_noise_model, lag, **kwargs)

Run fixed-lag RTS smoothing over timestamped records.

rts_smooth_records(records, *, transition_model, process_noise_model, **kwargs)

Run a full Rauch--Tung--Striebel pass over timestamped records.

smooth_records(records, *, method='fixed-lag', transition_model, process_noise_model, lag=None, time_key='time_s', state_key='state', covariance_key='covariance', output_state_key='state', output_covariance_key='covariance', filtered_state_key='filtered_state', filtered_covariance_key='filtered_covariance', metadata=None)

Return records with smoothed state/covariance estimates.

records may contain arbitrary extra metadata such as sensor source, accepted/rejected action, NIS, residuals, association IDs, or measurement dimensions. Returned records preserve that metadata and additionally store the original filtered state/covariance under filtered_* keys.

transition_model and process_noise_model are callables that accept dt seconds. They may optionally accept a second state_dim argument; this allows one function to support 6D CV, 7D bias states, or other linear state layouts.