rid {rsvd} | R Documentation |
Randomized interpolative decomposition (ID).
Description
Randomized interpolative decomposition.
Usage
rid(A, k = NULL, mode = "column", p = 10, q = 0, idx_only = FALSE, rand = TRUE)
Arguments
A |
array_like; |
k |
integer, optional; |
mode |
string c('column', 'row'), optional; |
p |
integer, optional; |
q |
integer, optional. |
idx_only |
bool, optional; |
rand |
bool, optional; |
Details
Algorithm for computing the ID of a rectangular matrix
, with target rank
. The input matrix is factored as
using the column pivoted QR decomposition. The factor matrix is formed as a subset of
columns of
, also called the partial column skeleton.
If
mode='row'
, then the input matrix is factored as
using the row pivoted QR decomposition. The factor matrix is now formed as
a subset of rows of
, also called the partial row skeleton.
The factor matrix
contains a
identity matrix as a submatrix,
and is well-conditioned.
If a probabilistic strategy is used to compute the decomposition, otherwise a
deterministic algorithm is used.
Value
rid
returns a list containing the following components:
- C
array_like;
column subset, if
mode='column'
; array with dimensions.
- R
array_like;
row subset, if
mode='row'
; array with dimensions.
- Z
array_like;
well conditioned matrix; Depending on the selected mode, this is an array with dimensionsor
.
- idx
array_like;
index set of theselected columns or rows used to form
or
.
- pivot
array_like;
information on the pivoting strategy used during the decomposition.- scores
array_like;
scores of the columns or rows of the input matrix.
- scores.idx
array_like;
scores of theselected columns or rows in
or
.
Author(s)
N. Benjamin Erichson, erichson@uw.edu
References
[1] N. Halko, P. Martinsson, and J. Tropp. "Finding structure with randomness: probabilistic algorithms for constructing approximate matrix decompositions" (2009). (available at arXiv https://arxiv.org/abs/0909.4061).
[2] N. B. Erichson, S. Voronin, S. L. Brunton and J. N. Kutz. 2019. Randomized Matrix Decompositions Using R. Journal of Statistical Software, 89(11), 1-48. doi: 10.18637/jss.v089.i11.
See Also
rcur
,
Examples
## Not run:
# Load test image
data("tiger")
# Compute (column) randomized interpolative decompsition
# Note that the image needs to be transposed for correct plotting
out <- rid(t(tiger), k = 150)
# Show selected columns
tiger.partial <- matrix(0, 1200, 1600)
tiger.partial[,out$idx] <- t(tiger)[,out$idx]
image(t(tiger.partial), col = gray((0:255)/255), useRaster = TRUE)
# Reconstruct image
tiger.re <- t(out$C %*% out$Z)
# Compute relative error
print(norm(tiger-tiger.re, 'F') / norm(tiger, 'F'))
# Plot approximated image
image(tiger.re, col = gray((0:255)/255))
## End(Not run)