freealg.submatrix#
- freealg.submatrix(matrix, size, paired=True, seed=None)#
Randomly sample a submatrix from a larger matrix.
- Parameters:
- matrixnumpy.ndarray
A 2D square array
- sizeint
Number of rows and columns of the submatrix
- pairedbool, default=True
If True, the rows and columns are sampled with the same random indices. If False, separate random indices are used for selecting rows and columns.
- seedint, default=None
Seed for random number generation. If None, results will not be reproducible.
- Returns:
- subnumpy.ndarray
A 2D array with the number of rows/columns specified by
size.
See also
Examples
>>> import numpy >>> from freealg import submatrix >>> A = numpy.random.randn(1000, 1000) >>> B = submatrix(A, size=500, paired=True, seed=0)