design_matrix#

detkit.design_matrix(num_rows=512, num_cols=256, ortho=False)#

Generate design matrix.

Parameters:
num_rowsint, default=2**9

Number of rows of the matrix.

num_colsint, default=2**8

Number of columns of the matrix.

orthobool, default=False

If True, the matrix is orthonormalized.

Returns:
Xnumpy.ndarray

A 2D array

Notes

The design matrix is created as follows:

\[\begin{split}X_{ij} = \begin{cases} 1 & j = 1, \\ \sin(t_i \pi j) & j = 2k, \\ \cos(t_i \pi j) & j = 2k+1, \end{cases}\end{split}\]

where \(t_i = \frac{i}{n}\) and \(n\) is the number of the rows of the matrix.

Orthonormalization:

The matrix \(\mathbf{X}\) is orthonormalized by Gram-Schmidt process using detkit.orthogonalize() function.

Examples

>>> import detkit
>>> n, m = 2**9, 2**2
>>> X = detkit.datasets.design_matrix(n, m, ortho=True)
[[ 0.04419417 -0.09094864  0.06243905 -0.09532571]
 [ 0.04419417 -0.09006862  0.06243787 -0.09299386]
 [ 0.04419417 -0.08918863  0.06243433 -0.09066257]
 ...
 [ 0.04419417 -0.08918863 -0.06243433 -0.09066257]
 [ 0.04419417 -0.09006862 -0.06243787 -0.09299386]
 [ 0.04419417 -0.09094864 -0.06243905 -0.09532571]]

Check if the above matrix is orthonormal: