kkf.systems#

Dynamical systems module.

Defines classes and utilities for representing general dynamical systems with state transitions and measurement functions.

Functions

create_additive_system(nx, ny, f, g, dist_X, ...)

Create an additive dynamical system where noise is added to the state and observation functions.

Classes

DynamicalSystem(nx, ny, f, g, dist_X, ...)

A class representing a general dynamical system with state and measurement equations.

class kkf.systems.DynamicalSystem(nx, ny, f, g, dist_X, dist_dyn, dist_obs, discrete_time)[source]#

Bases: object

A class representing a general dynamical system with state and measurement equations.

This class encapsulates the dynamics, measurements, and associated probability distributions for both state and measurement noise. Can be considered as:

Discrete time:

Dynamics: x_{k+1} = f(x_{k}) + w_{k} Measurements: y_{k} = g(x_{k}) + v_{k}

Continous time:

Dynamics: x’(t) = f(x(t)) + w(t) Measurements: y(t) = g(x(t)) + v(t)

Parameters:
nx#

Dimension of the state space.

Type:

int

ny#

Dimension of the measurement/output space.

Type:

int

f#

State transition function (dynamics).

Type:

Callable

g#

Measurement/output function.

Type:

Callable

dist_X#

Probability distribution for initial states.

Type:

rv_continuous

dist_dyn#

Probability distribution for dynamics noise.

Type:

rv_continuous

dist_obs#

Probability distribution for measurement noise.

Type:

rv_continuous

discrete_time#

Indicates if the system is in discrete time, if False the system is in continous time.

Type:

bool

Notes

The functions f and g model the noise-free dynamics and measurements; the noise terms w and v are added separately (see dynamics and measurements). They should have the following signatures: - f(x: ndarray) -> ndarray - g(x: ndarray) -> ndarray where x is the state vector. Both must also accept a batch of column vectors of shape (nx, n_features), since KoopmanOperator evaluates them on the full dictionary at once.

dynamics(x, w)[source]#

Apply the state transition function.

Parameters:
  • x (np.ndarray) – Current state vector.

  • w (np.ndarray) – Process noise vector.

Returns:

Next state vector.

Return type:

np.ndarray

measurements(x, v)[source]#

Apply the measurement function.

Parameters:
  • x (np.ndarray) – Current state vector.

  • v (np.ndarray) – Measurement noise vector.

Returns:

Measurement/output vector.

Return type:

np.ndarray

sample_state(size=1)[source]#

Sample from the state distribution.

Parameters:

size (int, optional) – Number of samples to draw. Default is 1.

Returns:

Sampled state(s).

Return type:

np.ndarray

kkf.systems.create_additive_system(nx, ny, f, g, dist_X, dist_dyn, dist_obs, N_samples, discrete_time=True)[source]#

Create an additive dynamical system where noise is added to the state and observation functions.

Parameters:
  • nx (int) – Dimension of the state space.

  • ny (int) – Dimension of the measurement space.

  • f (Callable) – State transition function (with noise).

  • g (Callable) – Measurement function (with noise).

  • dist_X (rv_continuous) – Initial state distribution.

  • dist_dyn (rv_continuous) – Dynamics noise distribution.

  • dist_obs (rv_continuous) – Measurement noise distribution.

  • N_samples (int) – Number of samples to generate empirical mean of dynamics and observation.

  • discrete_time (bool, optional) – Indicates if the system is in discrete time. Default is True.

Returns:

New dynamical system instance with additive noise.

Return type:

DynamicalSystem

Notes

The resulting system has the form: x[k+1] = f(x[k]) + w[k] y[k] = g(x[k]) + v[k] where w and v are noise terms.

Deprecated since version ``create_additive_system``: is deprecated and will be removed in a future major release. The state-dependent noise distributions it builds are incompatible with the covariance sampling used by apply_koopman_kalman_filter (which calls dist_dyn.rvs(size=...) without a state argument). Construct a DynamicalSystem directly instead, providing f/g as the noise-free maps.