Randomized Matrix Decompositions using R

N. Benjamin Erichson, Sergey Voronin, Steven L. Brunton, J. Nathan Kutz · DOI

Abstract

Matrix decompositions are fundamental tools in the area of applied mathematics, statistical computing, and machine learning. In particular, low-rank matrix decompositions are vital, and widely used for data analysis, dimensionality reduction, and data compression. Massive datasets, however, pose a computational challenge for traditional algorithms, placing significant constraints on both memory and processing power. Recently, the powerful concept of randomness has been introduced as a strategy to ease the computational load. The essential idea of probabilistic algorithms is to employ some amount of randomness in order to derive a smaller matrix from a high-dimensional data matrix. The smaller matrix is then used to compute the desired low-rank approximation. We present the R package rsvd, and provide a tutorial introduction to randomized matrix decompositions. Specifically, randomized routines for the singular value decomposition, (robust) principal component analysis, interpolative decomposition, and CUR decomposition are discussed. Several examples demonstrate the routines, and show the computational advantage over other methods implemented in R.

Introduction

In the era of "big data," we are drowning in information stored as massive matrices. Traditional workhorse algorithms, like the Singular Value Decomposition (SVD), are the backbone of dimensionality reduction and data compression. However, they are computationally expensive; a standard SVD for an $m \times n$ matrix scales at $O(mn^2)$, which becomes a significant barrier when dealing with datasets that exceed memory or require real-time processing.

Furthermore, the growth of data collection is currently outstripping gains in hardware performance. The rsvd package bridges this gap by offering a suite of randomized routines designed to handle large-scale datasets that feature an underlying low-rank structure—where the essential information is captured by a fraction of the total dimensions.

The Randomized Framework: "Randomize then Solve"

The core philosophy of the rsvd package is a two-stage probabilistic framework that reduces the computational burden by first "sketching" the data.

The two-stage randomized decomposition framework illustrating the transition from a "Big" matrix A to a "Small" matrix B via probabilistic sketching.
  1. Stage A (The Sketch): Instead of processing the whole matrix, the algorithm uses random projections (typically Gaussian) to identify a low-dimensional subspace that captures the "action" of the original matrix. This creates a "sketch" or a much smaller matrix that represents the original's column space.
  2. Stage B (The Solve): A standard, deterministic algorithm (like the "economy" SVD) is then applied to this tiny sketch. Finally, the results are projected back to the original high-dimensional space.

To improve accuracy, the package introduces specific "tuning knobs":

  • Oversampling ($p$): Using slightly more random projections than the target rank $k$ to ensure no important information is missed.
  • Power Iterations ($q$): Pre-processing the matrix to make its singular values decay faster, which significantly improves accuracy for matrices where information is "spread out" rather than concentrated in the top components.

Performance and Key Results

The authors evaluate the rsvd package using a mix of synthetic and real-world benchmarks, including random low-rank matrices, image compression tasks, and the MNIST handwritten digits database.

Speedups and Scalability

The primary advantage of the randomized approach is its massive speedup over traditional methods. For a $10,000 \times 5,000$ matrix, rsvd achieved a 120x speedup over the base R svd() function.

Speedup of rsvd compared to other SVD implementations (svd, propack, RSpectra, irlba) across varying matrix dimensions.

As shown in the benchmarks, rsvd consistently outperforms other popular "fast" packages like irlba and RSpectra as matrix dimensions increase.

Accuracy and Robustness

Crucially, this speed does not come at the cost of accuracy. In image compression tests, the randomized SVD ($q=2$) achieved a reconstruction error (NRMSE) of 0.122, nearly identical to the deterministic SVD's 0.121. On the MNIST dataset, using randomized PCA to reduce data to 40 components before classification resulted in an accuracy of 99.18%, matching the performance of deterministic PCA.

Discussion and Future Work

Deliberate randomness makes algorithms more robust for big data by allowing them to ignore high-dimensional noise and focus on core structures. Furthermore, these algorithms are "pass-efficient," typically requiring only two passes over the full data matrix, which is vital since data movement is often a greater bottleneck than computation in modern systems.

While rsvd offers significant advantages, the authors note that speedups are most pronounced for "fat" matrices. Future work aims to incorporate "structured" or "sparse" random projections for even greater efficiency at astronomical scales and to extend the framework to other statistical methods like Linear Discriminant Analysis (LDA) and Canonical Correlation Analysis (CCA).

Summary updated

BibTeX
@article{erichson2019randomized,
  author = {N. Benjamin Erichson and Sergey Voronin and Steven L. Brunton and J. Nathan Kutz},
  title = {{Randomized Matrix Decompositions using R}},
  journal = {Journal of Statistical Software},
  year = {2019},
  doi = {10.18637/jss.v089.i11},
}
Figure