Skip to content

base

Helper functions used by the Subspace Identification Methods and other useful functions for State Space models.

@author: Giuseppe Armenise

Functions:

Name Description
Vn_mat

Compute the variance of the model residuals

Z_dot_PIort

Compute the scalar product between a vector z and \(I - x^T \cdot pinv(X^T)\), avoiding the direct computation of the matrix

lsim_innovation_form

Simulate system in a innovation form.

lsim_predictor_form

Simulate system in a predictor form.

lsim_process_form

Simulate system in a process form.

Vn_mat

Vn_mat(y: ndarray, yest: ndarray) -> ndarray

Compute the variance of the model residuals

Parameters:

Name Type Description Default

y

(L*l,1) vectorized matrix of output of the process

required

yest

(L*l,1) vectorized matrix of output of the estimated model

required

Z_dot_PIort

Z_dot_PIort(z: ndarray, X: ndarray) -> ndarray

Compute the scalar product between a vector z and \(I - x^T \cdot pinv(X^T)\), avoiding the direct computation of the matrix

PI = np.dot(X.T, np.linalg.pinv(X.T)), causing high memory usage

Parameters:

Name Type Description Default

z

(...) vector array_like

required

X

(...) matrix array_like

required

lsim_innovation_form

lsim_innovation_form(
    A: ndarray,
    B: ndarray,
    C: ndarray,
    D: ndarray,
    K: ndarray,
    y: ndarray,
    u: ndarray,
    x0: ndarray | None = None,
)

Simulate system in a innovation form.

This function performs a simulation in the innovation form. This function is analogous to the previous one, using the system matrices $ A $ and $ B $ instead of $ A_K $ and $ B_K $

lsim_predictor_form

lsim_predictor_form(
    A_K: ndarray,
    B_K: ndarray,
    C: ndarray,
    D: ndarray,
    K: ndarray,
    y: ndarray,
    u: ndarray,
    x0: ndarray | None = None,
)

Simulate system in a predictor form.

This function performs a simulation in the predictor form, given the identified system matrices, the Kalman filter gain, the real output sequence (array with \(n_y\) rows and L columns, the input sequence (an array with \(n_u\) rows and L columns) and the initial state estimate (array with \(n\) rows and one column). The state sequence and the estimated output sequence are returned.

lsim_process_form

lsim_process_form(
    A: ndarray,
    B: ndarray,
    C: ndarray,
    D: ndarray,
    u: ndarray,
    x0: ndarray | None = None,
)

Simulate system in a process form.

This function performs a simulation in the process form, given the identified system matrices, the input sequence (an array with \(n_u\) rows and L columns) and the initial state estimate (array with \(n\) rows and one column).