utils¶
- class nfoursid.utils.Decomposition(left_orthogonal, eigenvalues, right_orthogonal)¶
Bases:
tupleEigenvalue decomposition of a matrix
matrixsuch thatleft_orthogonal @ eigenvalues @ right_orthogonalequalsmatrix.- 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
matrixwithnum_block_rowsblock rows. The shape ofmatrixis 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_rowsblock 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
matrixas aDecomposition.
- static reduce_decomposition(decomposition: nfoursid.utils.Decomposition, rank: int) nfoursid.utils.Decomposition¶
Reduce an eigenvalue decomposition
decompositionsuch that onlyranknumber of biggest eigenvalues remain. Returns anotherDecomposition.
- static unvectorize(vector: numpy.ndarray, num_rows: int) numpy.ndarray¶
Given a vector
vectorof 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
matrixdoes not have shapeshape. The error message will containname.
- static vectorize(matrix: numpy.ndarray) numpy.ndarray¶
Given a matrix
matrixof shape(a, b), return a vector of shape(a*b, 1)with all columns ofmatrixstacked on top of eachother.