Dynamic Models
Dynamic motion models for target tracking.
This module provides state transition matrices (F) and process noise covariance matrices (Q) for various motion models: - Constant velocity (CV) - Constant acceleration (CA) - Coordinated turn (2D and 3D) - Singer acceleration model - Nearly constant velocity/acceleration
It also provides continuous-time dynamics (drift and diffusion functions) and utilities for discretizing continuous-time models.
- pytcl.dynamic_models.f_poly_kal(order, T, num_dims=1)[source]
Create state transition matrix for polynomial Kalman filter model.
The polynomial model assumes constant highest derivative. For order=1 (constant velocity), the state is [position, velocity]. For order=2 (constant acceleration), state is [position, velocity, acceleration].
- Parameters:
order (int) – Order of the model: - 0: Constant position (random walk) - 1: Constant velocity (nearly constant velocity) - 2: Constant acceleration (nearly constant acceleration)
T (float) – Time step in seconds.
num_dims (int, optional) – Number of spatial dimensions (default: 1). For num_dims > 1, creates block diagonal matrix.
- Returns:
F – State transition matrix of shape ((order+1)*num_dims, (order+1)*num_dims).
- Return type:
ndarray
Examples
>>> # 1D constant velocity model >>> F = f_poly_kal(order=1, T=0.1) >>> F array([[1. , 0.1], [0. , 1. ]])
>>> # 2D constant velocity model >>> F = f_poly_kal(order=1, T=0.1, num_dims=2) >>> F.shape (4, 4)
Notes
The state vector is ordered as [x, vx, ax, y, vy, ay, …] for each dimension.
- pytcl.dynamic_models.f_constant_velocity(T, num_dims=3)[source]
Create state transition matrix for constant velocity (CV) model.
This is a convenience wrapper for f_poly_kal with order=1.
- Parameters:
- Returns:
F – State transition matrix of shape (2*num_dims, 2*num_dims).
- Return type:
ndarray
Examples
>>> F = f_constant_velocity(T=1.0, num_dims=2) >>> F array([[1., 1., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 1.], [0., 0., 0., 1.]])
See also
f_poly_kalGeneral polynomial model.
q_constant_velocityProcess noise for CV model.
- pytcl.dynamic_models.f_constant_acceleration(T, num_dims=3)[source]
Create state transition matrix for constant acceleration (CA) model.
This is a convenience wrapper for f_poly_kal with order=2.
- Parameters:
- Returns:
F – State transition matrix of shape (3*num_dims, 3*num_dims).
- Return type:
ndarray
Examples
>>> F = f_constant_acceleration(T=1.0, num_dims=1) >>> F array([[1. , 1. , 0.5], [0. , 1. , 1. ], [0. , 0. , 1. ]])
See also
f_poly_kalGeneral polynomial model.
q_constant_accelerationProcess noise for CA model.
- pytcl.dynamic_models.f_discrete_white_noise_accel(T, num_dims=3)[source]
Create state transition matrix for discrete white noise acceleration (DWNA).
This is equivalent to the constant velocity model but emphasizes that acceleration is modeled as discrete white noise.
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
See also
f_constant_velocitySame model, different naming convention.
- pytcl.dynamic_models.f_piecewise_white_noise_jerk(T, num_dims=3)[source]
Create state transition matrix for piecewise white noise jerk model.
This is the constant acceleration model where jerk (derivative of acceleration) is modeled as piecewise constant white noise.
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
See also
f_constant_accelerationSame model, different naming convention.
- pytcl.dynamic_models.f_coord_turn_2d(T, omega, state_type='position_velocity')[source]
Create state transition matrix for 2D coordinated turn model.
In a coordinated turn, the target moves in a circular arc with constant turn rate (angular velocity omega).
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
Examples
>>> import numpy as np >>> # Constant velocity (omega=0) reduces to CV model >>> F = f_coord_turn_2d(T=1.0, omega=0.0) >>> F array([[1., 1., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 1.], [0., 0., 0., 1.]])
>>> # 90 deg/s turn rate >>> F = f_coord_turn_2d(T=1.0, omega=np.pi/2)
Notes
- For the 2D coordinated turn, the dynamics are:
x’ = x + (sin(omega*T)/omega)*vx - ((1-cos(omega*T))/omega)*vy vx’ = cos(omega*T)*vx - sin(omega*T)*vy y’ = y + ((1-cos(omega*T))/omega)*vx + (sin(omega*T)/omega)*vy vy’ = sin(omega*T)*vx + cos(omega*T)*vy
When omega is near zero, L’Hopital’s rule gives the CV model.
See also
f_coord_turn_3d3D coordinated turn model.
- pytcl.dynamic_models.f_coord_turn_3d(T, omega, state_type='position_velocity')[source]
Create state transition matrix for 3D coordinated turn model.
In the 3D case, the turn occurs in the x-y plane while z motion follows constant velocity dynamics.
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
Examples
>>> F = f_coord_turn_3d(T=1.0, omega=0.1) >>> F.shape (6, 6)
See also
f_coord_turn_2d2D coordinated turn model.
- pytcl.dynamic_models.f_coord_turn_polar(T, omega, speed)[source]
Create state transition matrix for coordinated turn in polar form.
State vector is [x, y, heading, speed, turn_rate].
- Parameters:
- Returns:
F – State transition matrix of shape (5, 5).
- Return type:
ndarray
Notes
This is a linearized model around the current state. For accurate propagation, use the nonlinear equations directly.
The state is [x, y, psi, v, omega] where: - psi is heading angle - v is speed magnitude - omega is turn rate
Examples
>>> F = f_coord_turn_polar(T=1.0, omega=0.1, speed=100.0) >>> F.shape (5, 5)
- pytcl.dynamic_models.f_singer(T, tau, num_dims=1)[source]
Create state transition matrix for Singer acceleration model.
The Singer model assumes acceleration is a first-order Gauss-Markov process with time constant tau. State is [position, velocity, acceleration].
- Parameters:
- Returns:
F – State transition matrix of shape (3*num_dims, 3*num_dims).
- Return type:
ndarray
Examples
>>> F = f_singer(T=1.0, tau=10.0) >>> F array([[1. , 1. , 0.04837418], [0. , 1. , 0.90483742], [0. , 0. , 0.90483742]])
Notes
- The continuous-time model is:
dx/dt = v dv/dt = a da/dt = -a/tau + w(t)
where w(t) is white noise.
- The discrete-time transition is:
alpha = exp(-T/tau) F = [[1, T, (alpha*T + tau - tau*alpha - T)/alpha_tau],
[0, 1, tau*(1 - alpha)], [0, 0, alpha]]
where alpha_tau = 1/tau.
See also
q_singerProcess noise for Singer model.
References
- pytcl.dynamic_models.f_singer_2d(T, tau)[source]
Create state transition matrix for 2D Singer model.
State vector is [x, vx, ax, y, vy, ay].
- Parameters:
- Returns:
F – State transition matrix of shape (6, 6).
- Return type:
ndarray
Examples
>>> F = f_singer_2d(T=1.0, tau=10.0) >>> F.shape (6, 6)
See also
f_singerGeneral Singer model.
- pytcl.dynamic_models.f_singer_3d(T, tau)[source]
Create state transition matrix for 3D Singer model.
State vector is [x, vx, ax, y, vy, ay, z, vz, az].
- Parameters:
- Returns:
F – State transition matrix of shape (9, 9).
- Return type:
ndarray
Examples
>>> F = f_singer_3d(T=1.0, tau=10.0) >>> F.shape (9, 9)
See also
f_singerGeneral Singer model.
- pytcl.dynamic_models.q_poly_kal(order, T, q, num_dims=1)[source]
Create process noise covariance matrix for polynomial Kalman filter model.
- Parameters:
order (int) – Order of the model: - 0: Random walk - 1: Constant velocity (discrete white noise acceleration) - 2: Constant acceleration (discrete white noise jerk)
T (float) – Time step in seconds.
q (float) – Process noise intensity (spectral density). For order=1: acceleration variance [m²/s⁴] For order=2: jerk variance [m²/s⁶]
num_dims (int, optional) – Number of spatial dimensions (default: 1).
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> # 1D constant velocity with acceleration noise variance of 1 m²/s⁴ >>> Q = q_poly_kal(order=1, T=0.1, q=1.0) >>> Q array([[0.000025 , 0.0005 ], [0.0005 , 0.01 ]])
Notes
The process noise assumes discrete white noise on the highest derivative. For continuous-time models, use q_poly_kal_continuous.
- pytcl.dynamic_models.q_discrete_white_noise(dim, T, var, block_size=1)[source]
Create discrete white noise process noise matrix.
This is a general-purpose function for creating Q matrices where the noise enters at a specific derivative level.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> # 2D state (position, velocity) with acceleration noise >>> Q = q_discrete_white_noise(dim=2, T=1.0, var=1.0) >>> Q array([[0.25, 0.5 ], [0.5 , 1. ]])
- pytcl.dynamic_models.q_constant_velocity(T, sigma_a, num_dims=3)[source]
Create process noise covariance for constant velocity model.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> Q = q_constant_velocity(T=1.0, sigma_a=0.1, num_dims=2) >>> Q.shape (4, 4)
See also
f_constant_velocityState transition matrix for CV model.
- pytcl.dynamic_models.q_constant_acceleration(T, sigma_j, num_dims=3)[source]
Create process noise covariance for constant acceleration model.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> Q = q_constant_acceleration(T=1.0, sigma_j=0.1, num_dims=2) >>> Q.shape (6, 6)
See also
f_constant_accelerationState transition matrix for CA model.
- pytcl.dynamic_models.q_continuous_white_noise(dim, T, spectral_density, block_size=1)[source]
Create process noise matrix from continuous-time white noise model.
This assumes the continuous-time process noise has spectral density q, and computes the discrete-time covariance via integration.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Notes
For a continuous-time model with process noise spectral density q, the discrete-time process noise covariance is:
Q = integral_0^T exp(A*t) * G * q * G’ * exp(A’*t) dt
This function computes this integral analytically for polynomial models.
- pytcl.dynamic_models.q_singer(T, tau, sigma_m, num_dims=1)[source]
Create process noise covariance matrix for Singer acceleration model.
- Parameters:
- Returns:
Q – Process noise covariance matrix of shape (3*num_dims, 3*num_dims).
- Return type:
ndarray
Examples
>>> Q = q_singer(T=1.0, tau=10.0, sigma_m=1.0) >>> Q.shape (3, 3)
Notes
- The Singer model assumes acceleration is a first-order Gauss-Markov process:
da/dt = -a/tau + w(t)
where w(t) is white noise with spectral density 2*sigma_m²/tau.
The discrete-time process noise covariance is computed by integrating the continuous-time dynamics.
See also
f_singerState transition matrix for Singer model.
References
[1] Singer, R.A., “Estimating Optimal Tracking Filter Performance for Manned Maneuvering Targets”, IEEE Trans. AES, 1970.
- pytcl.dynamic_models.q_singer_2d(T, tau, sigma_m)[source]
Create process noise covariance for 2D Singer model.
- pytcl.dynamic_models.q_singer_3d(T, tau, sigma_m)[source]
Create process noise covariance for 3D Singer model.
- pytcl.dynamic_models.q_coord_turn_2d(T, sigma_a, sigma_omega=0.0, state_type='position_velocity')[source]
Create process noise covariance for 2D coordinated turn model.
- Parameters:
T (float) – Time step in seconds.
sigma_a (float) – Standard deviation of acceleration noise [m/s²].
sigma_omega (float, optional) – Standard deviation of turn rate noise [rad/s²]. Only used if state_type includes omega.
state_type (str, optional) – State vector composition: - ‘position_velocity’: [x, vx, y, vy] (default) - ‘position_velocity_omega’: [x, vx, y, vy, omega]
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> Q = q_coord_turn_2d(T=1.0, sigma_a=1.0) >>> Q.shape (4, 4)
Notes
The process noise accounts for uncertainty in the turn dynamics. For the coordinated turn, this includes uncertainty in both the linear acceleration and the turn rate.
See also
f_coord_turn_2dState transition matrix for 2D coordinated turn.
- pytcl.dynamic_models.q_coord_turn_3d(T, sigma_a, sigma_omega=0.0, state_type='position_velocity')[source]
Create process noise covariance for 3D coordinated turn model.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
See also
f_coord_turn_3dState transition matrix for 3D coordinated turn.
- pytcl.dynamic_models.q_coord_turn_polar(T, sigma_a, sigma_omega_dot)[source]
Create process noise covariance for coordinated turn in polar form.
State vector is [x, y, heading, speed, turn_rate].
- pytcl.dynamic_models.drift_constant_velocity(x, t=0.0, num_dims=3)[source]
Drift function for constant velocity model.
- Parameters:
- Returns:
a – Drift vector (time derivative of state).
- Return type:
ndarray
Examples
>>> x = np.array([0, 1, 0, 2, 0, 3]) # 3D: pos=0, vel=[1,2,3] >>> a = drift_constant_velocity(x, num_dims=3) >>> a array([1., 0., 2., 0., 3., 0.])
- pytcl.dynamic_models.drift_constant_acceleration(x, t=0.0, num_dims=3)[source]
Drift function for constant acceleration model.
- Parameters:
- Returns:
a – Drift vector.
- Return type:
ndarray
Examples
>>> x = np.array([0, 10, 1]) # 1D: pos=0, vel=10, acc=1 >>> a = drift_constant_acceleration(x, num_dims=1) >>> a # [vel, acc, 0] array([10., 1., 0.])
- pytcl.dynamic_models.drift_singer(x, t=0.0, tau=10.0, num_dims=1)[source]
Drift function for Singer acceleration model.
- Parameters:
- Returns:
a – Drift vector.
- Return type:
ndarray
Notes
- The Singer model has acceleration following a first-order Markov process:
da/dt = -a/tau + w(t)
Examples
>>> x = np.array([0, 10, 2]) # 1D: pos=0, vel=10, acc=2 >>> a = drift_singer(x, tau=5.0, num_dims=1) >>> a # [vel, acc, -acc/tau] array([10. , 2. , -0.4])
- pytcl.dynamic_models.drift_coordinated_turn_2d(x, t=0.0)[source]
Drift function for 2D coordinated turn model.
- Parameters:
x (array_like) – State vector [x, vx, y, vy, omega].
t (float, optional) – Time (not used).
- Returns:
a – Drift vector.
- Return type:
ndarray
Notes
- The coordinated turn dynamics are:
dx/dt = vx dvx/dt = -omega * vy dy/dt = vy dvy/dt = omega * vx domega/dt = 0
Examples
>>> # Aircraft at origin with velocity [100, 0] and turn rate 0.1 rad/s >>> x = np.array([0, 100, 0, 0, 0.1]) >>> a = drift_coordinated_turn_2d(x) >>> a # [vx, -omega*vy, vy, omega*vx, 0] array([ 100., -0., 0., 10., 0.])
- pytcl.dynamic_models.diffusion_constant_velocity(x, t=0.0, sigma_a=1.0, num_dims=3)[source]
Diffusion matrix for constant velocity model with acceleration noise.
- Parameters:
- Returns:
D – Diffusion matrix (noise enters through velocity derivative).
- Return type:
ndarray
Examples
>>> x = np.array([0, 1, 0, 2]) # 2D state (not used) >>> D = diffusion_constant_velocity(x, sigma_a=0.5, num_dims=2) >>> D.shape (4, 2) >>> D # Noise enters velocity states only array([[0. , 0. ], [0.5, 0. ], [0. , 0. ], [0. , 0.5]])
- pytcl.dynamic_models.diffusion_constant_acceleration(x, t=0.0, sigma_j=1.0, num_dims=3)[source]
Diffusion matrix for constant acceleration model with jerk noise.
- Parameters:
- Returns:
D – Diffusion matrix.
- Return type:
ndarray
Examples
>>> x = np.array([0, 1, 0.5]) # 1D state (not used) >>> D = diffusion_constant_acceleration(x, sigma_j=0.1, num_dims=1) >>> D.shape (3, 1) >>> D # Noise enters acceleration state only array([[0. ], [0. ], [0.1]])
- pytcl.dynamic_models.diffusion_singer(x, t=0.0, sigma_m=1.0, tau=10.0, num_dims=1)[source]
Diffusion matrix for Singer model.
- Parameters:
- Returns:
D – Diffusion matrix.
- Return type:
ndarray
Notes
The diffusion coefficient for Singer is sqrt(2*sigma_m^2/tau).
Examples
>>> x = np.array([0, 1, 0.5]) # 1D state (not used) >>> D = diffusion_singer(x, sigma_m=1.0, tau=10.0, num_dims=1) >>> D.shape (3, 1) >>> D[2, 0] # sqrt(2*1^2/10) = sqrt(0.2) 0.4472135954999579
- pytcl.dynamic_models.continuous_to_discrete(A, G, Q_c, T)[source]
Convert continuous-time model to discrete-time using Van Loan method.
- Given continuous-time model:
dx/dt = A*x + G*w, E[w*w’] = Q_c
- Compute discrete-time model:
x_{k+1} = F*x_k + v_k, E[v_k*v_k’] = Q_d
- Parameters:
A (array_like) – Continuous-time state matrix.
G (array_like) – Noise input matrix.
Q_c (array_like) – Continuous-time process noise covariance.
T (float) – Time step in seconds.
- Returns:
F (ndarray) – Discrete-time state transition matrix.
Q_d (ndarray) – Discrete-time process noise covariance.
- Return type:
Tuple[ndarray[tuple[Any, …], dtype[floating]], ndarray[tuple[Any, …], dtype[floating]]]
Examples
>>> # 1D constant velocity model >>> A = np.array([[0, 1], [0, 0]]) >>> G = np.array([[0], [1]]) >>> Q_c = np.array([[1.0]]) # acceleration variance >>> F, Q_d = continuous_to_discrete(A, G, Q_c, T=0.1)
Notes
Uses the Van Loan method which computes F and Q_d by exponentiating the augmented matrix:
- M = [[-A, G*Q_c*G’],
[ 0, A’]] * T
- exp(M) = [[ *, F^{-1}*Q_d],
[ 0, F’ ]]
References
[1] Van Loan, C.F., “Computing Integrals Involving the Matrix Exponential”, IEEE Trans. Automatic Control, 1978.
Examples
>>> # 1D constant velocity model >>> A = np.array([[0, 1], [0, 0]]) >>> G = np.array([[0], [1]]) >>> Q_c = np.array([[1.0]]) # acceleration variance >>> F, Q_d = continuous_to_discrete(A, G, Q_c, T=0.1) >>> F # State transition matrix array([[1. , 0.1], [0. , 1. ]])
- pytcl.dynamic_models.discretize_lti(A, B=None, T=1.0)[source]
Discretize a linear time-invariant system.
- Given continuous-time system:
dx/dt = A*x + B*u
- Compute discrete-time system:
x_{k+1} = F*x_k + G*u_k
- Parameters:
A (array_like) – Continuous-time state matrix.
B (array_like, optional) – Continuous-time input matrix.
T (float, optional) – Time step in seconds.
- Returns:
F (ndarray) – Discrete-time state transition matrix.
G (ndarray or None) – Discrete-time input matrix (None if B is None).
- Return type:
Tuple[ndarray[tuple[Any, …], dtype[floating]], ndarray[tuple[Any, …], dtype[floating]] | None]
Examples
>>> # 1D constant velocity: dx/dt = v, dv/dt = u (control input) >>> A = np.array([[0, 1], [0, 0]]) >>> B = np.array([[0], [1]]) >>> F, G = discretize_lti(A, B, T=0.1) >>> F # State transition array([[1. , 0.1], [0. , 1. ]]) >>> G # Input matrix array([[0.005], [0.1 ]])
- pytcl.dynamic_models.state_jacobian_cv(x, num_dims=3)[source]
State Jacobian (A matrix) for constant velocity model.
- Parameters:
x (array_like) – State vector (not used, included for interface consistency).
num_dims (int, optional) – Number of spatial dimensions.
- Returns:
A – Continuous-time state matrix.
- Return type:
ndarray
Examples
>>> x = np.array([0, 1]) # 1D state (not used) >>> A = state_jacobian_cv(x, num_dims=1) >>> A array([[0., 1.], [0., 0.]])
- pytcl.dynamic_models.state_jacobian_ca(x, num_dims=3)[source]
State Jacobian (A matrix) for constant acceleration model.
- Parameters:
x (array_like) – State vector (not used).
num_dims (int, optional) – Number of spatial dimensions.
- Returns:
A – Continuous-time state matrix.
- Return type:
ndarray
Examples
>>> x = np.array([0, 1, 0.5]) # 1D state (not used) >>> A = state_jacobian_ca(x, num_dims=1) >>> A array([[0., 1., 0.], [0., 0., 1.], [0., 0., 0.]])
- pytcl.dynamic_models.state_jacobian_singer(x, tau=10.0, num_dims=1)[source]
State Jacobian (A matrix) for Singer acceleration model.
- Parameters:
- Returns:
A – Continuous-time state matrix.
- Return type:
ndarray
Examples
>>> x = np.array([0, 1, 0.5]) # 1D state (not used) >>> A = state_jacobian_singer(x, tau=5.0, num_dims=1) >>> A array([[ 0. , 1. , 0. ], [ 0. , 0. , 1. ], [ 0. , 0. , -0.2]])
Discrete-Time Models
Discrete-time state transition models.
This module provides state transition matrices (F) for various motion models used in target tracking applications.
- pytcl.dynamic_models.discrete_time.f_poly_kal(order, T, num_dims=1)[source]
Create state transition matrix for polynomial Kalman filter model.
The polynomial model assumes constant highest derivative. For order=1 (constant velocity), the state is [position, velocity]. For order=2 (constant acceleration), state is [position, velocity, acceleration].
- Parameters:
order (int) – Order of the model: - 0: Constant position (random walk) - 1: Constant velocity (nearly constant velocity) - 2: Constant acceleration (nearly constant acceleration)
T (float) – Time step in seconds.
num_dims (int, optional) – Number of spatial dimensions (default: 1). For num_dims > 1, creates block diagonal matrix.
- Returns:
F – State transition matrix of shape ((order+1)*num_dims, (order+1)*num_dims).
- Return type:
ndarray
Examples
>>> # 1D constant velocity model >>> F = f_poly_kal(order=1, T=0.1) >>> F array([[1. , 0.1], [0. , 1. ]])
>>> # 2D constant velocity model >>> F = f_poly_kal(order=1, T=0.1, num_dims=2) >>> F.shape (4, 4)
Notes
The state vector is ordered as [x, vx, ax, y, vy, ay, …] for each dimension.
- pytcl.dynamic_models.discrete_time.f_constant_velocity(T, num_dims=3)[source]
Create state transition matrix for constant velocity (CV) model.
This is a convenience wrapper for f_poly_kal with order=1.
- Parameters:
- Returns:
F – State transition matrix of shape (2*num_dims, 2*num_dims).
- Return type:
ndarray
Examples
>>> F = f_constant_velocity(T=1.0, num_dims=2) >>> F array([[1., 1., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 1.], [0., 0., 0., 1.]])
See also
f_poly_kalGeneral polynomial model.
q_constant_velocityProcess noise for CV model.
- pytcl.dynamic_models.discrete_time.f_constant_acceleration(T, num_dims=3)[source]
Create state transition matrix for constant acceleration (CA) model.
This is a convenience wrapper for f_poly_kal with order=2.
- Parameters:
- Returns:
F – State transition matrix of shape (3*num_dims, 3*num_dims).
- Return type:
ndarray
Examples
>>> F = f_constant_acceleration(T=1.0, num_dims=1) >>> F array([[1. , 1. , 0.5], [0. , 1. , 1. ], [0. , 0. , 1. ]])
See also
f_poly_kalGeneral polynomial model.
q_constant_accelerationProcess noise for CA model.
- pytcl.dynamic_models.discrete_time.f_discrete_white_noise_accel(T, num_dims=3)[source]
Create state transition matrix for discrete white noise acceleration (DWNA).
This is equivalent to the constant velocity model but emphasizes that acceleration is modeled as discrete white noise.
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
See also
f_constant_velocitySame model, different naming convention.
- pytcl.dynamic_models.discrete_time.f_piecewise_white_noise_jerk(T, num_dims=3)[source]
Create state transition matrix for piecewise white noise jerk model.
This is the constant acceleration model where jerk (derivative of acceleration) is modeled as piecewise constant white noise.
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
See also
f_constant_accelerationSame model, different naming convention.
- pytcl.dynamic_models.discrete_time.f_coord_turn_2d(T, omega, state_type='position_velocity')[source]
Create state transition matrix for 2D coordinated turn model.
In a coordinated turn, the target moves in a circular arc with constant turn rate (angular velocity omega).
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
Examples
>>> import numpy as np >>> # Constant velocity (omega=0) reduces to CV model >>> F = f_coord_turn_2d(T=1.0, omega=0.0) >>> F array([[1., 1., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 1.], [0., 0., 0., 1.]])
>>> # 90 deg/s turn rate >>> F = f_coord_turn_2d(T=1.0, omega=np.pi/2)
Notes
- For the 2D coordinated turn, the dynamics are:
x’ = x + (sin(omega*T)/omega)*vx - ((1-cos(omega*T))/omega)*vy vx’ = cos(omega*T)*vx - sin(omega*T)*vy y’ = y + ((1-cos(omega*T))/omega)*vx + (sin(omega*T)/omega)*vy vy’ = sin(omega*T)*vx + cos(omega*T)*vy
When omega is near zero, L’Hopital’s rule gives the CV model.
See also
f_coord_turn_3d3D coordinated turn model.
- pytcl.dynamic_models.discrete_time.f_coord_turn_3d(T, omega, state_type='position_velocity')[source]
Create state transition matrix for 3D coordinated turn model.
In the 3D case, the turn occurs in the x-y plane while z motion follows constant velocity dynamics.
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
Examples
>>> F = f_coord_turn_3d(T=1.0, omega=0.1) >>> F.shape (6, 6)
See also
f_coord_turn_2d2D coordinated turn model.
- pytcl.dynamic_models.discrete_time.f_coord_turn_polar(T, omega, speed)[source]
Create state transition matrix for coordinated turn in polar form.
State vector is [x, y, heading, speed, turn_rate].
- Parameters:
- Returns:
F – State transition matrix of shape (5, 5).
- Return type:
ndarray
Notes
This is a linearized model around the current state. For accurate propagation, use the nonlinear equations directly.
The state is [x, y, psi, v, omega] where: - psi is heading angle - v is speed magnitude - omega is turn rate
Examples
>>> F = f_coord_turn_polar(T=1.0, omega=0.1, speed=100.0) >>> F.shape (5, 5)
- pytcl.dynamic_models.discrete_time.f_singer(T, tau, num_dims=1)[source]
Create state transition matrix for Singer acceleration model.
The Singer model assumes acceleration is a first-order Gauss-Markov process with time constant tau. State is [position, velocity, acceleration].
- Parameters:
- Returns:
F – State transition matrix of shape (3*num_dims, 3*num_dims).
- Return type:
ndarray
Examples
>>> F = f_singer(T=1.0, tau=10.0) >>> F array([[1. , 1. , 0.04837418], [0. , 1. , 0.90483742], [0. , 0. , 0.90483742]])
Notes
- The continuous-time model is:
dx/dt = v dv/dt = a da/dt = -a/tau + w(t)
where w(t) is white noise.
- The discrete-time transition is:
alpha = exp(-T/tau) F = [[1, T, (alpha*T + tau - tau*alpha - T)/alpha_tau],
[0, 1, tau*(1 - alpha)], [0, 0, alpha]]
where alpha_tau = 1/tau.
See also
q_singerProcess noise for Singer model.
References
[1] Singer, R.A., “Estimating Optimal Tracking Filter Performance for Manned Maneuvering Targets”, IEEE Trans. on Aerospace and Electronic Systems, Vol. AES-6, No. 4, July 1970.
- pytcl.dynamic_models.discrete_time.f_singer_2d(T, tau)[source]
Create state transition matrix for 2D Singer model.
State vector is [x, vx, ax, y, vy, ay].
- Parameters:
- Returns:
F – State transition matrix of shape (6, 6).
- Return type:
ndarray
Examples
>>> F = f_singer_2d(T=1.0, tau=10.0) >>> F.shape (6, 6)
See also
f_singerGeneral Singer model.
- pytcl.dynamic_models.discrete_time.f_singer_3d(T, tau)[source]
Create state transition matrix for 3D Singer model.
State vector is [x, vx, ax, y, vy, ay, z, vz, az].
- Parameters:
- Returns:
F – State transition matrix of shape (9, 9).
- Return type:
ndarray
Examples
>>> F = f_singer_3d(T=1.0, tau=10.0) >>> F.shape (9, 9)
See also
f_singerGeneral Singer model.
Polynomial Models
Polynomial (constant velocity/acceleration) state transition models.
This module provides F matrices for polynomial motion models where the state consists of position, velocity, and optionally acceleration components.
- pytcl.dynamic_models.discrete_time.polynomial.f_poly_kal(order, T, num_dims=1)[source]
Create state transition matrix for polynomial Kalman filter model.
The polynomial model assumes constant highest derivative. For order=1 (constant velocity), the state is [position, velocity]. For order=2 (constant acceleration), state is [position, velocity, acceleration].
- Parameters:
order (int) – Order of the model: - 0: Constant position (random walk) - 1: Constant velocity (nearly constant velocity) - 2: Constant acceleration (nearly constant acceleration)
T (float) – Time step in seconds.
num_dims (int, optional) – Number of spatial dimensions (default: 1). For num_dims > 1, creates block diagonal matrix.
- Returns:
F – State transition matrix of shape ((order+1)*num_dims, (order+1)*num_dims).
- Return type:
ndarray
Examples
>>> # 1D constant velocity model >>> F = f_poly_kal(order=1, T=0.1) >>> F array([[1. , 0.1], [0. , 1. ]])
>>> # 2D constant velocity model >>> F = f_poly_kal(order=1, T=0.1, num_dims=2) >>> F.shape (4, 4)
Notes
The state vector is ordered as [x, vx, ax, y, vy, ay, …] for each dimension.
- pytcl.dynamic_models.discrete_time.polynomial.f_constant_velocity(T, num_dims=3)[source]
Create state transition matrix for constant velocity (CV) model.
This is a convenience wrapper for f_poly_kal with order=1.
- Parameters:
- Returns:
F – State transition matrix of shape (2*num_dims, 2*num_dims).
- Return type:
ndarray
Examples
>>> F = f_constant_velocity(T=1.0, num_dims=2) >>> F array([[1., 1., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 1.], [0., 0., 0., 1.]])
See also
f_poly_kalGeneral polynomial model.
q_constant_velocityProcess noise for CV model.
- pytcl.dynamic_models.discrete_time.polynomial.f_constant_acceleration(T, num_dims=3)[source]
Create state transition matrix for constant acceleration (CA) model.
This is a convenience wrapper for f_poly_kal with order=2.
- Parameters:
- Returns:
F – State transition matrix of shape (3*num_dims, 3*num_dims).
- Return type:
ndarray
Examples
>>> F = f_constant_acceleration(T=1.0, num_dims=1) >>> F array([[1. , 1. , 0.5], [0. , 1. , 1. ], [0. , 0. , 1. ]])
See also
f_poly_kalGeneral polynomial model.
q_constant_accelerationProcess noise for CA model.
- pytcl.dynamic_models.discrete_time.polynomial.f_discrete_white_noise_accel(T, num_dims=3)[source]
Create state transition matrix for discrete white noise acceleration (DWNA).
This is equivalent to the constant velocity model but emphasizes that acceleration is modeled as discrete white noise.
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
See also
f_constant_velocitySame model, different naming convention.
- pytcl.dynamic_models.discrete_time.polynomial.f_piecewise_white_noise_jerk(T, num_dims=3)[source]
Create state transition matrix for piecewise white noise jerk model.
This is the constant acceleration model where jerk (derivative of acceleration) is modeled as piecewise constant white noise.
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
See also
f_constant_accelerationSame model, different naming convention.
Singer Model
Singer acceleration model.
The Singer model treats target acceleration as a first-order Markov process (exponentially correlated random variable), providing a more realistic model for maneuvering targets than constant acceleration.
- pytcl.dynamic_models.discrete_time.singer.f_singer(T, tau, num_dims=1)[source]
Create state transition matrix for Singer acceleration model.
The Singer model assumes acceleration is a first-order Gauss-Markov process with time constant tau. State is [position, velocity, acceleration].
- Parameters:
- Returns:
F – State transition matrix of shape (3*num_dims, 3*num_dims).
- Return type:
ndarray
Examples
>>> F = f_singer(T=1.0, tau=10.0) >>> F array([[1. , 1. , 0.04837418], [0. , 1. , 0.90483742], [0. , 0. , 0.90483742]])
Notes
- The continuous-time model is:
dx/dt = v dv/dt = a da/dt = -a/tau + w(t)
where w(t) is white noise.
- The discrete-time transition is:
alpha = exp(-T/tau) F = [[1, T, (alpha*T + tau - tau*alpha - T)/alpha_tau],
[0, 1, tau*(1 - alpha)], [0, 0, alpha]]
where alpha_tau = 1/tau.
See also
q_singerProcess noise for Singer model.
References
[1] Singer, R.A., “Estimating Optimal Tracking Filter Performance for Manned Maneuvering Targets”, IEEE Trans. on Aerospace and Electronic Systems, Vol. AES-6, No. 4, July 1970.
- pytcl.dynamic_models.discrete_time.singer.f_singer_2d(T, tau)[source]
Create state transition matrix for 2D Singer model.
State vector is [x, vx, ax, y, vy, ay].
- Parameters:
- Returns:
F – State transition matrix of shape (6, 6).
- Return type:
ndarray
Examples
>>> F = f_singer_2d(T=1.0, tau=10.0) >>> F.shape (6, 6)
See also
f_singerGeneral Singer model.
- pytcl.dynamic_models.discrete_time.singer.f_singer_3d(T, tau)[source]
Create state transition matrix for 3D Singer model.
State vector is [x, vx, ax, y, vy, ay, z, vz, az].
- Parameters:
- Returns:
F – State transition matrix of shape (9, 9).
- Return type:
ndarray
Examples
>>> F = f_singer_3d(T=1.0, tau=10.0) >>> F.shape (9, 9)
See also
f_singerGeneral Singer model.
Coordinated Turn
Coordinated turn motion models.
This module provides state transition matrices for 2D and 3D coordinated turn models, commonly used for tracking maneuvering aircraft.
- pytcl.dynamic_models.discrete_time.coordinated_turn.f_coord_turn_2d(T, omega, state_type='position_velocity')[source]
Create state transition matrix for 2D coordinated turn model.
In a coordinated turn, the target moves in a circular arc with constant turn rate (angular velocity omega).
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
Examples
>>> import numpy as np >>> # Constant velocity (omega=0) reduces to CV model >>> F = f_coord_turn_2d(T=1.0, omega=0.0) >>> F array([[1., 1., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 1.], [0., 0., 0., 1.]])
>>> # 90 deg/s turn rate >>> F = f_coord_turn_2d(T=1.0, omega=np.pi/2)
Notes
- For the 2D coordinated turn, the dynamics are:
x’ = x + (sin(omega*T)/omega)*vx - ((1-cos(omega*T))/omega)*vy vx’ = cos(omega*T)*vx - sin(omega*T)*vy y’ = y + ((1-cos(omega*T))/omega)*vx + (sin(omega*T)/omega)*vy vy’ = sin(omega*T)*vx + cos(omega*T)*vy
When omega is near zero, L’Hopital’s rule gives the CV model.
See also
f_coord_turn_3d3D coordinated turn model.
- pytcl.dynamic_models.discrete_time.coordinated_turn.f_coord_turn_3d(T, omega, state_type='position_velocity')[source]
Create state transition matrix for 3D coordinated turn model.
In the 3D case, the turn occurs in the x-y plane while z motion follows constant velocity dynamics.
- Parameters:
- Returns:
F – State transition matrix.
- Return type:
ndarray
Examples
>>> F = f_coord_turn_3d(T=1.0, omega=0.1) >>> F.shape (6, 6)
See also
f_coord_turn_2d2D coordinated turn model.
- pytcl.dynamic_models.discrete_time.coordinated_turn.f_coord_turn_polar(T, omega, speed)[source]
Create state transition matrix for coordinated turn in polar form.
State vector is [x, y, heading, speed, turn_rate].
- Parameters:
- Returns:
F – State transition matrix of shape (5, 5).
- Return type:
ndarray
Notes
This is a linearized model around the current state. For accurate propagation, use the nonlinear equations directly.
The state is [x, y, psi, v, omega] where: - psi is heading angle - v is speed magnitude - omega is turn rate
Examples
>>> F = f_coord_turn_polar(T=1.0, omega=0.1, speed=100.0) >>> F.shape (5, 5)
Process Noise
Process noise covariance matrices.
This module provides process noise covariance matrices (Q) for various motion models used in target tracking applications.
- pytcl.dynamic_models.process_noise.q_poly_kal(order, T, q, num_dims=1)[source]
Create process noise covariance matrix for polynomial Kalman filter model.
- Parameters:
order (int) – Order of the model: - 0: Random walk - 1: Constant velocity (discrete white noise acceleration) - 2: Constant acceleration (discrete white noise jerk)
T (float) – Time step in seconds.
q (float) – Process noise intensity (spectral density). For order=1: acceleration variance [m²/s⁴] For order=2: jerk variance [m²/s⁶]
num_dims (int, optional) – Number of spatial dimensions (default: 1).
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> # 1D constant velocity with acceleration noise variance of 1 m²/s⁴ >>> Q = q_poly_kal(order=1, T=0.1, q=1.0) >>> Q array([[0.000025 , 0.0005 ], [0.0005 , 0.01 ]])
Notes
The process noise assumes discrete white noise on the highest derivative. For continuous-time models, use q_poly_kal_continuous.
- pytcl.dynamic_models.process_noise.q_discrete_white_noise(dim, T, var, block_size=1)[source]
Create discrete white noise process noise matrix.
This is a general-purpose function for creating Q matrices where the noise enters at a specific derivative level.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> # 2D state (position, velocity) with acceleration noise >>> Q = q_discrete_white_noise(dim=2, T=1.0, var=1.0) >>> Q array([[0.25, 0.5 ], [0.5 , 1. ]])
- pytcl.dynamic_models.process_noise.q_constant_velocity(T, sigma_a, num_dims=3)[source]
Create process noise covariance for constant velocity model.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> Q = q_constant_velocity(T=1.0, sigma_a=0.1, num_dims=2) >>> Q.shape (4, 4)
See also
f_constant_velocityState transition matrix for CV model.
- pytcl.dynamic_models.process_noise.q_constant_acceleration(T, sigma_j, num_dims=3)[source]
Create process noise covariance for constant acceleration model.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> Q = q_constant_acceleration(T=1.0, sigma_j=0.1, num_dims=2) >>> Q.shape (6, 6)
See also
f_constant_accelerationState transition matrix for CA model.
- pytcl.dynamic_models.process_noise.q_continuous_white_noise(dim, T, spectral_density, block_size=1)[source]
Create process noise matrix from continuous-time white noise model.
This assumes the continuous-time process noise has spectral density q, and computes the discrete-time covariance via integration.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Notes
For a continuous-time model with process noise spectral density q, the discrete-time process noise covariance is:
Q = integral_0^T exp(A*t) * G * q * G’ * exp(A’*t) dt
This function computes this integral analytically for polynomial models.
- pytcl.dynamic_models.process_noise.q_singer(T, tau, sigma_m, num_dims=1)[source]
Create process noise covariance matrix for Singer acceleration model.
- Parameters:
- Returns:
Q – Process noise covariance matrix of shape (3*num_dims, 3*num_dims).
- Return type:
ndarray
Examples
>>> Q = q_singer(T=1.0, tau=10.0, sigma_m=1.0) >>> Q.shape (3, 3)
Notes
- The Singer model assumes acceleration is a first-order Gauss-Markov process:
da/dt = -a/tau + w(t)
where w(t) is white noise with spectral density 2*sigma_m²/tau.
The discrete-time process noise covariance is computed by integrating the continuous-time dynamics.
See also
f_singerState transition matrix for Singer model.
References
[1] Singer, R.A., “Estimating Optimal Tracking Filter Performance for Manned Maneuvering Targets”, IEEE Trans. AES, 1970.
- pytcl.dynamic_models.process_noise.q_singer_2d(T, tau, sigma_m)[source]
Create process noise covariance for 2D Singer model.
- pytcl.dynamic_models.process_noise.q_singer_3d(T, tau, sigma_m)[source]
Create process noise covariance for 3D Singer model.
- pytcl.dynamic_models.process_noise.q_coord_turn_2d(T, sigma_a, sigma_omega=0.0, state_type='position_velocity')[source]
Create process noise covariance for 2D coordinated turn model.
- Parameters:
T (float) – Time step in seconds.
sigma_a (float) – Standard deviation of acceleration noise [m/s²].
sigma_omega (float, optional) – Standard deviation of turn rate noise [rad/s²]. Only used if state_type includes omega.
state_type (str, optional) – State vector composition: - ‘position_velocity’: [x, vx, y, vy] (default) - ‘position_velocity_omega’: [x, vx, y, vy, omega]
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> Q = q_coord_turn_2d(T=1.0, sigma_a=1.0) >>> Q.shape (4, 4)
Notes
The process noise accounts for uncertainty in the turn dynamics. For the coordinated turn, this includes uncertainty in both the linear acceleration and the turn rate.
See also
f_coord_turn_2dState transition matrix for 2D coordinated turn.
- pytcl.dynamic_models.process_noise.q_coord_turn_3d(T, sigma_a, sigma_omega=0.0, state_type='position_velocity')[source]
Create process noise covariance for 3D coordinated turn model.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
See also
f_coord_turn_3dState transition matrix for 3D coordinated turn.
- pytcl.dynamic_models.process_noise.q_coord_turn_polar(T, sigma_a, sigma_omega_dot)[source]
Create process noise covariance for coordinated turn in polar form.
State vector is [x, y, heading, speed, turn_rate].
Polynomial Process Noise
Process noise covariance matrices for polynomial motion models.
This module provides Q matrices for constant velocity, constant acceleration, and higher-order polynomial models.
- pytcl.dynamic_models.process_noise.polynomial.q_poly_kal(order, T, q, num_dims=1)[source]
Create process noise covariance matrix for polynomial Kalman filter model.
- Parameters:
order (int) – Order of the model: - 0: Random walk - 1: Constant velocity (discrete white noise acceleration) - 2: Constant acceleration (discrete white noise jerk)
T (float) – Time step in seconds.
q (float) – Process noise intensity (spectral density). For order=1: acceleration variance [m²/s⁴] For order=2: jerk variance [m²/s⁶]
num_dims (int, optional) – Number of spatial dimensions (default: 1).
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> # 1D constant velocity with acceleration noise variance of 1 m²/s⁴ >>> Q = q_poly_kal(order=1, T=0.1, q=1.0) >>> Q array([[0.000025 , 0.0005 ], [0.0005 , 0.01 ]])
Notes
The process noise assumes discrete white noise on the highest derivative. For continuous-time models, use q_poly_kal_continuous.
- pytcl.dynamic_models.process_noise.polynomial.q_discrete_white_noise(dim, T, var, block_size=1)[source]
Create discrete white noise process noise matrix.
This is a general-purpose function for creating Q matrices where the noise enters at a specific derivative level.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> # 2D state (position, velocity) with acceleration noise >>> Q = q_discrete_white_noise(dim=2, T=1.0, var=1.0) >>> Q array([[0.25, 0.5 ], [0.5 , 1. ]])
- pytcl.dynamic_models.process_noise.polynomial.q_constant_velocity(T, sigma_a, num_dims=3)[source]
Create process noise covariance for constant velocity model.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> Q = q_constant_velocity(T=1.0, sigma_a=0.1, num_dims=2) >>> Q.shape (4, 4)
See also
f_constant_velocityState transition matrix for CV model.
- pytcl.dynamic_models.process_noise.polynomial.q_constant_acceleration(T, sigma_j, num_dims=3)[source]
Create process noise covariance for constant acceleration model.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> Q = q_constant_acceleration(T=1.0, sigma_j=0.1, num_dims=2) >>> Q.shape (6, 6)
See also
f_constant_accelerationState transition matrix for CA model.
- pytcl.dynamic_models.process_noise.polynomial.q_continuous_white_noise(dim, T, spectral_density, block_size=1)[source]
Create process noise matrix from continuous-time white noise model.
This assumes the continuous-time process noise has spectral density q, and computes the discrete-time covariance via integration.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Notes
For a continuous-time model with process noise spectral density q, the discrete-time process noise covariance is:
Q = integral_0^T exp(A*t) * G * q * G’ * exp(A’*t) dt
This function computes this integral analytically for polynomial models.
Singer Process Noise
Process noise covariance matrices for Singer acceleration model.
This module provides functions to construct process noise covariance matrices (Q matrices) for the Singer acceleration motion model. The Singer model treats target acceleration as a first-order Gauss-Markov process, making it well-suited for tracking maneuvering targets with random accelerations.
The Singer model is characterized by: - A maneuver time constant (tau) that controls how quickly acceleration
correlations decay
An RMS maneuver level (sigma_m) that sets the expected acceleration magnitude
State vector [position, velocity, acceleration] per dimension
- The model dynamics are:
da/dt = -a/tau + w(t)
where w(t) is white noise with spectral density 2*sigma_m²/tau.
Available functions:
- q_singer: Generic N-dimensional Singer process noise
- q_singer_2d: 2D Singer model (6x6 state)
- q_singer_3d: 3D Singer model (9x9 state)
These Q matrices are designed to work with the corresponding state transition
matrices in pytcl.dynamic_models.singer.
Examples
Create process noise for tracking a maneuvering aircraft:
>>> from pytcl.dynamic_models.process_noise import q_singer
>>> Q = q_singer(T=1.0, tau=20.0, sigma_m=3.0) # tau=20s, 3g maneuvers
>>> Q.shape
(3, 3)
For 3D tracking:
>>> Q = q_singer_3d(T=0.1, tau=10.0, sigma_m=2.0)
>>> Q.shape
(9, 9)
See also
pytcl.dynamic_models.singerState transition matrices
pytcl.dynamic_models.process_noise.constant_accelerationCA process noise
References
Singer, R.A., “Estimating Optimal Tracking Filter Performance for Manned Maneuvering Targets”, IEEE Trans. Aerospace and Electronic Systems, Vol. AES-6, No. 4, July 1970, pp. 473-483.
Bar-Shalom, Y., Li, X.R., and Kirubarajan, T., “Estimation with Applications to Tracking and Navigation”, Wiley, 2001, Chapter 6.
- pytcl.dynamic_models.process_noise.singer.q_singer(T, tau, sigma_m, num_dims=1)[source]
Create process noise covariance matrix for Singer acceleration model.
- Parameters:
- Returns:
Q – Process noise covariance matrix of shape (3*num_dims, 3*num_dims).
- Return type:
ndarray
Examples
>>> Q = q_singer(T=1.0, tau=10.0, sigma_m=1.0) >>> Q.shape (3, 3)
Notes
- The Singer model assumes acceleration is a first-order Gauss-Markov process:
da/dt = -a/tau + w(t)
where w(t) is white noise with spectral density 2*sigma_m²/tau.
The discrete-time process noise covariance is computed by integrating the continuous-time dynamics.
See also
f_singerState transition matrix for Singer model.
References
[1] Singer, R.A., “Estimating Optimal Tracking Filter Performance for Manned Maneuvering Targets”, IEEE Trans. AES, 1970.
- pytcl.dynamic_models.process_noise.singer.q_singer_2d(T, tau, sigma_m)[source]
Create process noise covariance for 2D Singer model.
Coordinated Turn Process Noise
Process noise covariance matrices for coordinated turn models.
This module provides functions to construct process noise covariance matrices (Q matrices) for coordinated turn motion models used in target tracking. Coordinated turn models describe targets that maintain a constant turn rate, such as aircraft executing banking maneuvers.
The process noise captures uncertainty in the target’s motion, including: - Linear acceleration uncertainty along the velocity direction - Turn rate (angular velocity) uncertainty
Available functions:
- q_coord_turn_2d: 2D coordinated turn (planar motion)
- q_coord_turn_3d: 3D coordinated turn (spatial motion)
- q_coord_turn_polar: Polar/heading-speed representation
These Q matrices are designed to work with the corresponding state transition
matrices in pytcl.dynamic_models.coordinated_turn.
Examples
Create process noise for a 2D coordinated turn tracker:
>>> from pytcl.dynamic_models.process_noise import q_coord_turn_2d
>>> Q = q_coord_turn_2d(T=0.1, sigma_a=2.0) # 0.1s step, 2 m/s² accel noise
>>> Q.shape
(4, 4)
With turn rate state estimation:
>>> Q = q_coord_turn_2d(T=0.1, sigma_a=2.0, sigma_omega=0.01,
... state_type='position_velocity_omega')
>>> Q.shape
(5, 5)
See also
pytcl.dynamic_models.coordinated_turnState transition matrices
pytcl.dynamic_models.process_noise.constant_velocityCV process noise
pytcl.dynamic_models.process_noise.constant_accelerationCA process noise
References
Bar-Shalom, Y., Li, X.R., and Kirubarajan, T., “Estimation with Applications to Tracking and Navigation”, Wiley, 2001.
Blackman, S. and Popoli, R., “Design and Analysis of Modern Tracking Systems”, Artech House, 1999.
- pytcl.dynamic_models.process_noise.coordinated_turn.q_coord_turn_2d(T, sigma_a, sigma_omega=0.0, state_type='position_velocity')[source]
Create process noise covariance for 2D coordinated turn model.
- Parameters:
T (float) – Time step in seconds.
sigma_a (float) – Standard deviation of acceleration noise [m/s²].
sigma_omega (float, optional) – Standard deviation of turn rate noise [rad/s²]. Only used if state_type includes omega.
state_type (str, optional) – State vector composition: - ‘position_velocity’: [x, vx, y, vy] (default) - ‘position_velocity_omega’: [x, vx, y, vy, omega]
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
Examples
>>> Q = q_coord_turn_2d(T=1.0, sigma_a=1.0) >>> Q.shape (4, 4)
Notes
The process noise accounts for uncertainty in the turn dynamics. For the coordinated turn, this includes uncertainty in both the linear acceleration and the turn rate.
See also
f_coord_turn_2dState transition matrix for 2D coordinated turn.
- pytcl.dynamic_models.process_noise.coordinated_turn.q_coord_turn_3d(T, sigma_a, sigma_omega=0.0, state_type='position_velocity')[source]
Create process noise covariance for 3D coordinated turn model.
- Parameters:
- Returns:
Q – Process noise covariance matrix.
- Return type:
ndarray
See also
f_coord_turn_3dState transition matrix for 3D coordinated turn.
Continuous-Time Dynamics
Continuous-time dynamic models.
This module provides drift and diffusion functions for continuous-time stochastic differential equations, as well as utilities for discretization.
- pytcl.dynamic_models.continuous_time.drift_constant_velocity(x, t=0.0, num_dims=3)[source]
Drift function for constant velocity model.
- Parameters:
- Returns:
a – Drift vector (time derivative of state).
- Return type:
ndarray
Examples
>>> x = np.array([0, 1, 0, 2, 0, 3]) # 3D: pos=0, vel=[1,2,3] >>> a = drift_constant_velocity(x, num_dims=3) >>> a array([1., 0., 2., 0., 3., 0.])
- pytcl.dynamic_models.continuous_time.drift_constant_acceleration(x, t=0.0, num_dims=3)[source]
Drift function for constant acceleration model.
- Parameters:
- Returns:
a – Drift vector.
- Return type:
ndarray
Examples
>>> x = np.array([0, 10, 1]) # 1D: pos=0, vel=10, acc=1 >>> a = drift_constant_acceleration(x, num_dims=1) >>> a # [vel, acc, 0] array([10., 1., 0.])
- pytcl.dynamic_models.continuous_time.drift_singer(x, t=0.0, tau=10.0, num_dims=1)[source]
Drift function for Singer acceleration model.
- Parameters:
- Returns:
a – Drift vector.
- Return type:
ndarray
Notes
- The Singer model has acceleration following a first-order Markov process:
da/dt = -a/tau + w(t)
Examples
>>> x = np.array([0, 10, 2]) # 1D: pos=0, vel=10, acc=2 >>> a = drift_singer(x, tau=5.0, num_dims=1) >>> a # [vel, acc, -acc/tau] array([10. , 2. , -0.4])
- pytcl.dynamic_models.continuous_time.drift_coordinated_turn_2d(x, t=0.0)[source]
Drift function for 2D coordinated turn model.
- Parameters:
x (array_like) – State vector [x, vx, y, vy, omega].
t (float, optional) – Time (not used).
- Returns:
a – Drift vector.
- Return type:
ndarray
Notes
- The coordinated turn dynamics are:
dx/dt = vx dvx/dt = -omega * vy dy/dt = vy dvy/dt = omega * vx domega/dt = 0
Examples
>>> # Aircraft at origin with velocity [100, 0] and turn rate 0.1 rad/s >>> x = np.array([0, 100, 0, 0, 0.1]) >>> a = drift_coordinated_turn_2d(x) >>> a # [vx, -omega*vy, vy, omega*vx, 0] array([ 100., -0., 0., 10., 0.])
- pytcl.dynamic_models.continuous_time.diffusion_constant_velocity(x, t=0.0, sigma_a=1.0, num_dims=3)[source]
Diffusion matrix for constant velocity model with acceleration noise.
- Parameters:
- Returns:
D – Diffusion matrix (noise enters through velocity derivative).
- Return type:
ndarray
Examples
>>> x = np.array([0, 1, 0, 2]) # 2D state (not used) >>> D = diffusion_constant_velocity(x, sigma_a=0.5, num_dims=2) >>> D.shape (4, 2) >>> D # Noise enters velocity states only array([[0. , 0. ], [0.5, 0. ], [0. , 0. ], [0. , 0.5]])
- pytcl.dynamic_models.continuous_time.diffusion_constant_acceleration(x, t=0.0, sigma_j=1.0, num_dims=3)[source]
Diffusion matrix for constant acceleration model with jerk noise.
- Parameters:
- Returns:
D – Diffusion matrix.
- Return type:
ndarray
Examples
>>> x = np.array([0, 1, 0.5]) # 1D state (not used) >>> D = diffusion_constant_acceleration(x, sigma_j=0.1, num_dims=1) >>> D.shape (3, 1) >>> D # Noise enters acceleration state only array([[0. ], [0. ], [0.1]])
- pytcl.dynamic_models.continuous_time.diffusion_singer(x, t=0.0, sigma_m=1.0, tau=10.0, num_dims=1)[source]
Diffusion matrix for Singer model.
- Parameters:
- Returns:
D – Diffusion matrix.
- Return type:
ndarray
Notes
The diffusion coefficient for Singer is sqrt(2*sigma_m^2/tau).
Examples
>>> x = np.array([0, 1, 0.5]) # 1D state (not used) >>> D = diffusion_singer(x, sigma_m=1.0, tau=10.0, num_dims=1) >>> D.shape (3, 1) >>> D[2, 0] # sqrt(2*1^2/10) = sqrt(0.2) 0.4472135954999579
- pytcl.dynamic_models.continuous_time.continuous_to_discrete(A, G, Q_c, T)[source]
Convert continuous-time model to discrete-time using Van Loan method.
- Given continuous-time model:
dx/dt = A*x + G*w, E[w*w’] = Q_c
- Compute discrete-time model:
x_{k+1} = F*x_k + v_k, E[v_k*v_k’] = Q_d
- Parameters:
A (array_like) – Continuous-time state matrix.
G (array_like) – Noise input matrix.
Q_c (array_like) – Continuous-time process noise covariance.
T (float) – Time step in seconds.
- Returns:
F (ndarray) – Discrete-time state transition matrix.
Q_d (ndarray) – Discrete-time process noise covariance.
- Return type:
Tuple[ndarray[tuple[Any, …], dtype[floating]], ndarray[tuple[Any, …], dtype[floating]]]
Examples
>>> # 1D constant velocity model >>> A = np.array([[0, 1], [0, 0]]) >>> G = np.array([[0], [1]]) >>> Q_c = np.array([[1.0]]) # acceleration variance >>> F, Q_d = continuous_to_discrete(A, G, Q_c, T=0.1)
Notes
Uses the Van Loan method which computes F and Q_d by exponentiating the augmented matrix:
- M = [[-A, G*Q_c*G’],
[ 0, A’]] * T
- exp(M) = [[ *, F^{-1}*Q_d],
[ 0, F’ ]]
References
[1] Van Loan, C.F., “Computing Integrals Involving the Matrix Exponential”, IEEE Trans. Automatic Control, 1978.
Examples
>>> # 1D constant velocity model >>> A = np.array([[0, 1], [0, 0]]) >>> G = np.array([[0], [1]]) >>> Q_c = np.array([[1.0]]) # acceleration variance >>> F, Q_d = continuous_to_discrete(A, G, Q_c, T=0.1) >>> F # State transition matrix array([[1. , 0.1], [0. , 1. ]])
- pytcl.dynamic_models.continuous_time.discretize_lti(A, B=None, T=1.0)[source]
Discretize a linear time-invariant system.
- Given continuous-time system:
dx/dt = A*x + B*u
- Compute discrete-time system:
x_{k+1} = F*x_k + G*u_k
- Parameters:
A (array_like) – Continuous-time state matrix.
B (array_like, optional) – Continuous-time input matrix.
T (float, optional) – Time step in seconds.
- Returns:
F (ndarray) – Discrete-time state transition matrix.
G (ndarray or None) – Discrete-time input matrix (None if B is None).
- Return type:
Tuple[ndarray[tuple[Any, …], dtype[floating]], ndarray[tuple[Any, …], dtype[floating]] | None]
Examples
>>> # 1D constant velocity: dx/dt = v, dv/dt = u (control input) >>> A = np.array([[0, 1], [0, 0]]) >>> B = np.array([[0], [1]]) >>> F, G = discretize_lti(A, B, T=0.1) >>> F # State transition array([[1. , 0.1], [0. , 1. ]]) >>> G # Input matrix array([[0.005], [0.1 ]])
- pytcl.dynamic_models.continuous_time.state_jacobian_cv(x, num_dims=3)[source]
State Jacobian (A matrix) for constant velocity model.
- Parameters:
x (array_like) – State vector (not used, included for interface consistency).
num_dims (int, optional) – Number of spatial dimensions.
- Returns:
A – Continuous-time state matrix.
- Return type:
ndarray
Examples
>>> x = np.array([0, 1]) # 1D state (not used) >>> A = state_jacobian_cv(x, num_dims=1) >>> A array([[0., 1.], [0., 0.]])
- pytcl.dynamic_models.continuous_time.state_jacobian_ca(x, num_dims=3)[source]
State Jacobian (A matrix) for constant acceleration model.
- Parameters:
x (array_like) – State vector (not used).
num_dims (int, optional) – Number of spatial dimensions.
- Returns:
A – Continuous-time state matrix.
- Return type:
ndarray
Examples
>>> x = np.array([0, 1, 0.5]) # 1D state (not used) >>> A = state_jacobian_ca(x, num_dims=1) >>> A array([[0., 1., 0.], [0., 0., 1.], [0., 0., 0.]])
- pytcl.dynamic_models.continuous_time.state_jacobian_singer(x, tau=10.0, num_dims=1)[source]
State Jacobian (A matrix) for Singer acceleration model.
- Parameters:
- Returns:
A – Continuous-time state matrix.
- Return type:
ndarray
Examples
>>> x = np.array([0, 1, 0.5]) # 1D state (not used) >>> A = state_jacobian_singer(x, tau=5.0, num_dims=1) >>> A array([[ 0. , 1. , 0. ], [ 0. , 0. , 1. ], [ 0. , 0. , -0.2]])