utils¶
- class nfoursid.utils.Decomposition(left_orthogonal, eigenvalues, right_orthogonal)¶
Bases:
tuple
Eigenvalue decomposition of a matrix
matrix
such thatleft_orthogonal @ eigenvalues @ right_orthogonal
equalsmatrix
.- property eigenvalues¶
Alias for field number 1
- property left_orthogonal¶
Alias for field number 0
- property right_orthogonal¶
Alias for field number 2
- class nfoursid.utils.Utils¶
Bases:
object
- static block_hankel_matrix(matrix: numpy.ndarray, num_block_rows: int) numpy.ndarray ¶
Calculate a block Hankel matrix based on input matrix
matrix
withnum_block_rows
block rows. The shape ofmatrix
is interpreted in row-order, like the structure of apd.DataFrame
: the rows are measurements and the columns are data sources.The returned block Hankel matrix has a columnar structure. Every column of the returned matrix consists of
num_block_rows
block rows (measurements). See the examples for details.Suppose that the input matrix contains 4 measurements of 2-dimensional data:
>>> matrix = np.array([ >>> [0, 1], >>> [2, 3], >>> [4, 5], >>> [6, 7] >>> ])
If the number of block rows is set to
num_block_rows=2
, then the block Hankel matrix will be>>> np.array([ >>> [0, 2, 4], >>> [1, 3, 5], >>> [2, 4, 6], >>> [3, 5, 7] >>> ])
- static eigenvalue_decomposition(matrix: numpy.ndarray) nfoursid.utils.Decomposition ¶
Calculate eigenvalue decomposition of
matrix
as aDecomposition
.
- static reduce_decomposition(decomposition: nfoursid.utils.Decomposition, rank: int) nfoursid.utils.Decomposition ¶
Reduce an eigenvalue decomposition
decomposition
such that onlyrank
number of biggest eigenvalues remain. Returns anotherDecomposition
.
- static unvectorize(vector: numpy.ndarray, num_rows: int) numpy.ndarray ¶
Given a vector
vector
of shape(num_rows*b, 1)
, return a matrix of shape(num_rows, b)
such that the stacked columns of the returned matrix equalvector
.
- static validate_matrix_shape(matrix: numpy.ndarray, shape: Tuple[float, float], name: str)¶
Raises if
matrix
does not have shapeshape
. The error message will containname
.
- static vectorize(matrix: numpy.ndarray) numpy.ndarray ¶
Given a matrix
matrix
of shape(a, b)
, return a vector of shape(a*b, 1)
with all columns ofmatrix
stacked on top of eachother.