Skip to content

arx

Created on Wed Jul 26 2017

@author: Giuseppe Armenise

Functions:

Name Description
ARX_MISO_id

Auto-Regressive with eXogenous Inputs model (ARX) identification.

ARX_id

Auto-Regressive with eXogenous Inputs model (ARX) identification.

compute_num_den

Compute the numerator and denominator coefficients.

compute_phi

Compute the regressor matrix PHI.

compute_theta

Computes the parameter vector THETA, the model output y_id, and the estimated error norm Vn.

ARX_MISO_id

ARX_MISO_id(
    y: ndarray,
    u: ndarray,
    na: int,
    nb: ndarray,
    theta: ndarray,
) -> tuple[
    ndarray, ndarray, ndarray, ndarray, floating, ndarray
]

Auto-Regressive with eXogenous Inputs model (ARX) identification.

Identified through the computation of the pseudo-inverse of the regressor matrix ($ \phi $).

Parameters:

Name Type Description Default

y

ndarray

Measured data

required

u

ndarray

Input data

required

na

int

Order of the autoregressive part.

required

nb

ndarray

Order of the exogenous part.

required

theta

ndarray

Delay of the exogenous part.

required

Returns:

Name Type Description
numerator ndarray
denominator ndarray
numerator_h ndarray
denominator_h ndarray
Vn floating

The estimated error norm.

y_id ndarray

The model output including non-identified outputs.

ARX_id

ARX_id(
    y: ndarray,
    u: ndarray,
    na: int,
    nb: ndarray,
    theta: ndarray,
    y_std: float = 1.0,
    U_std: ndarray = array(1.0),
) -> tuple[
    ndarray, ndarray, ndarray, ndarray, floating, ndarray
]

Auto-Regressive with eXogenous Inputs model (ARX) identification.

Identified through the computation of the pseudo-inverse of the regressor matrix ($ \phi $).

Parameters:

Name Type Description Default

y

ndarray

Measured data

required

u

ndarray

Input data

required

na

int

Order of the autoregressive part.

required

nb

ndarray

Order of the exogenous part.

required

theta

ndarray

Delay of the exogenous part.

required

y_std

float

Standard deviation of the output data.

1.0

U_std

ndarray

Standard deviation of the input data.

array(1.0)

Returns:

Name Type Description
numerator ndarray
denominator ndarray
numerator_h ndarray
denominator_h ndarray
Vn floating

The estimated error norm.

y_id ndarray

The model output including non-identified outputs.

compute_num_den

compute_num_den(
    THETA: ndarray,
    na: int,
    nb: ndarray,
    theta: ndarray,
    val: int,
    udim: int = 1,
    y_std: ndarray | float = 1.0,
    U_std: ndarray | float = array(1.0),
) -> tuple[ndarray, ndarray]

Compute the numerator and denominator coefficients.

Parameters:

Name Type Description Default

THETA

ndarray

Coefficient vector.

required

na

int

Order of the autoregressive part.

required

nb

ndarray

Order of the exogenous part.

required

theta

ndarray

Delay of the exogenous part.

required

val

int

Maximum predictable order.

required

udim

int

Dimension of the input data.

1

y_std

ndarray | float

Standard deviation of the output data.

1.0

U_std

ndarray | float

Standard deviation of the input data.

array(1.0)

Returns:

Name Type Description
tuple tuple[ndarray, ndarray]

Denominator coefficients, numerator coefficients, and numerator_h.

Examples:

>>> THETA = np.array([0.5, -0.2, 0.3, 0.1])
>>> na = 2
>>> nb = np.array([2])
>>> theta = np.array([1])
>>> val = 3
>>> udim = 1
>>> compute_num_den(THETA, na, nb, theta, val, udim)
(array([0. , 0.3, 0.1]), array([ 1. ,  0.5, -0.2,  0. ]))
>>> THETA = np.array([0.5, -0.2, 0.3, 0.1, 0.4, 0.2])
>>> na = 2
>>> nb = np.array([2, 2])
>>> theta = np.array([1, 1])
>>> val = 3
>>> udim = 2
>>> compute_num_den(THETA, na, nb, theta, val, udim, y_std=1, U_std=[1.0, 1.0])
(array([[0. , 0.3, 0.1],
    [0. , 0.4, 0.2]]), array([[ 1. ,  0.5, -0.2,  0. ],
    [ 1. ,  0.5, -0.2,  0. ]]))

compute_phi

compute_phi(
    y: ndarray,
    u: ndarray,
    na: int,
    nb: ndarray,
    theta: ndarray,
    val: int,
    N: int,
    udim: int = 1,
) -> ndarray

Compute the regressor matrix PHI.

Parameters:

Name Type Description Default

y

ndarray

Output data.

required

u

ndarray

Input data.

required

na

int

Order of the autoregressive part.

required

nb

ndarray

Order of the exogenous part.

required

theta

ndarray

Delay of the exogenous part.

required

val

int

Maximum predictable order.

required

N

int

Number of data points.

required

udim

int

Dimension of the input data.

1

Returns:

Type Description
ndarray

Regressor matrix PHI.

Examples:

>>> y = np.array([1, 2, 3, 4, 5])
>>> u = np.array([1, 2, 3, 4, 5])
>>> na = 2
>>> nb = np.array([2])
>>> theta = np.array([1])
>>> val = 2
>>> N = 3
>>> compute_phi(y, u, na, nb, theta, val, N, udim=1)
array([[-2., -1.,  2.,  1.],
    [-3., -2.,  3.,  2.],
    [-4., -3.,  4.,  3.]])
>>> y = np.array([1, 2, 3, 4, 5])
>>> u = np.array([[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]])
>>> na = 2
>>> nb = np.array([2, 2])
>>> theta = np.array([1, 1])
>>> val = 2
>>> N = 3
>>> compute_phi(y, u, na, nb, theta, val, N, udim=2)
array([[-2., -1.,  1.,  1.,  5.,  5.],
    [-3., -2.,  2.,  1.,  4.,  5.],
    [-4., -3.,  3.,  2.,  3.,  4.]])

compute_theta

compute_theta(
    PHI: ndarray, y: ndarray, val: int, y_std=1.0
) -> tuple[ndarray, ndarray, floating]

Computes the parameter vector THETA, the model output y_id, and the estimated error norm Vn.

Parameters:

Name Type Description Default

PHI

ndarray

The regression matrix.

required

y

ndarray

The output vector.

required

val

int

The index from which to start the validation.

required

Returns:

Name Type Description
THETA ndarray

The parameter vector.

y_id ndarray

The model output including non-identified outputs.

Vn floating

The estimated error norm.

Examples:

>>> import numpy as np
>>> PHI = np.array([[1, 2], [3, 4], [5, 6]])
>>> y = np.array([1, 2, 3, 4])
>>> val = 1
>>> THETA, y_id, Vn = compute_theta(PHI, y, val)
>>> THETA
array([-1. ,  1.5])
>>> y_id
array([1., 2., 3., 4.])
>>> round(Vn, 6)
np.float64(0.0)