Learn R Programming

rsvd (version 0.6)

rrpca: Randomized robust principal component analysis (rrpca).

Description

Robust principal components analysis using randomized singular value decomposition.

Usage

rrpca(A, k = NULL, lamb = NULL, gamma = 1.25, rho = 1.5, maxiter = 50, tol = 0.001, svdalg = "auto", p = 10, q = 1, trace = FALSE, ...)

Arguments

A
array_like a numeric input matrix (or data frame), with dimensions $(m, n)$. If the data contain $NA$s na.omit is applied.
k
int, optional determines the number of principle components to compute. It is required that $k$ is smaller or equal to $n$, but it is recommended that $k << min(m,n)$.
lamb
real, optional tuning paramter (default $lamb=max(m,n)^-0.5$).
gamma
real, optional tuning paramter (default $gamma=1.25$).
rho
real, optional tuning paramter (default $rho=1.5$).
maxiter
int, optional determines the maximal numbers of iterations (default $maxiter=20$)..
tol
real, optional tolarance paramter for the desired convergence of the algorithm.
svdalg
str c('auto', 'rsvd', 'svd'), optional Determines which algorithm should be used for computing the singular value decomposition. By default 'auto' is used, which decides whether to use rsvd or svd, depending on the number of principle components. If $k < min(n,m)/1.5$ randomized svd is used.
p
int, optional oversampling parameter for $rsvd$ (default $p=0$), see rsvd.
q
int, optional number of power iterations for $rsvd$ (default $q=1$), see rsvd.
trace
bool, optional print progress.
...
arguments passed to or from other methods, see rsvd.
.................
.

Value

rrpca returns a list with class $rrpca$ containing the following components:

Details

Robust principal component analysis (RPCA) is a method for the robust seperation of a a rectangular $(m,n)$ matrix $A$ into a low-rank component $L$ and a sparse comonent $S$ as follows: $A=L+S$. Here we are using the fast randomized accelerated inexact augmented Lagrange multiplier method (IALM) for obtaining the robust seperation.

References

  • [1] Lin, Zhouchen, Minming Chen, and Yi Ma. "The augmented lagrange multiplier method for exact recovery of corrupted low-rank matrices." (2010). (available at arXiv http://arxiv.org/abs/1009.5055).
  • [2] Candes, Emmanuel J., et al. "Robust principal component analysis?." Journal of the ACM (JACM) 58.3 (2011).

Examples

Run this code
library(rsvd)

# Create toy video
# background frame
xy <- seq(-50, 50, length.out=100)
mgrid <- list( x=outer(xy*0,xy,FUN="+"), y=outer(xy,xy*0,FUN="+") )
bg <- 0.1*exp(sin(-mgrid$x**2-mgrid$y**2))
toyVideo <- matrix(rep(c(bg), 100), 100*100, 100)

# add moving object
for(i in 1:90) {
  mobject <- matrix(0, 100, 100)
  mobject[i:(10+i), 45:55] <- 0.2
  toyVideo[,i] =  toyVideo[,i] + c( mobject )
}

# Foreground/Background separation
out <- rrpca(toyVideo, k=1, p=5, q=1, svdalg='rsvd', trace=TRUE)

# Display results of the seperation for the 10th frame
par(mfrow=c(1,4))
image(matrix(bg, ncol=100, nrow=100)) #true background
image(matrix(toyVideo[,10], ncol=100, nrow=100)) # frame
image(matrix(out$L[,10], ncol=100, nrow=100)) # seperated background
image(matrix(out$S[,10], ncol=100, nrow=100)) #seperated foreground

Run the code above in your browser using DataLab