randomSVD {RESET} | R Documentation |
Implementation of a sparse powered randomized singular value decomposition.
Description
Computes an approximate rank k
singular value decomposition (SVD) of an n-by-p input matrix X
using a sparse randomized embedding with optional subspace power iterations. The randomColumnSpace
method is used to generate an rank k
approximation of the column space of X
. This n-by-k approximation Y
is then used to create a k-by-p projection B
of X
onto this rank k
subspace via B=Y^TX
. A non-random SVD is computed for B
and this SVD solution is used to generate an approximate rank k
SVD of X
.
Usage
randomSVD(X, k=2, q=0, sparsity.structure=NULL, test.dist="normal")
Arguments
X |
An n-by-p target matrix. |
k |
Target rank. Defaults to 2. See description in |
q |
Number of power iterations. Defaults to 0. See description in |
sparsity.structure |
Optional sparsity structure. See description in |
test.dist |
Type of random variable used to populate non-sparse elements of random test matrix.
See description in |
Value
List with the following elements:
-
u
a matrix whose columns are the top k approximate left singular vectors ofX
. -
d
a vector containing the top k approximate singular values ofX
. -
v
a matrix whose columns are the top k approximate right singular vectors ofX
.
See Also
Examples
# Simulate a 100-by-100 matrix of random Poisson data
X = matrix(rpois(10000, lambda=2), nrow=100)
# Create a random sparsity structure for 100-by-5 random test matrix; half elements will be 0
sparsity.structure = sample(1:500, 250, replace=TRUE)
# Compute rank 5 SVD of X using a sparse test matrix
svd.out = randomSVD(X,k=5,sparsity.structure=sparsity.structure)
# Compute using a dense test matrix with U(0,1) RVs
svd.out = randomSVD(X,k=5,test.dist="uniform")