Online Row Sampling

Michael B. Cohen, Cameron Musco, Jakub Pachocki

Abstract

Finding a small spectral approximation for a tall $n \times d$ matrix $A$ is a fundamental numerical primitive. Row sampling improves interpretability, saves space when $A$ is sparse, and preserves row structure—a property especially important when $A$ represents a graph. However, correctly sampling rows can be costly when the matrix is too large to be stored in memory. While previous work has addressed row sampling in the streaming setting, we extend this to the more restrictive online setting: rows of $A$ arrive one by one, and we must immediately decide whether to keep or discard each row without ever retracting these decisions. We present an extremely simple algorithm that approximates $A$ up to multiplicative error $\epsilon$ and additive error $\delta$ using $O(d \log d \log(\epsilon||A||_2/\delta)/\epsilon^2)$ online samples. We also present an algorithm that uses $O(d^2)$ memory but requires only $O(d\log(\epsilon||A||_2/\delta)/\epsilon^2)$ samples, which we show is optimal. Our methods are clean and intuitive, allow for lower memory usage than prior work, and expose new theoretical properties of leverage score-based matrix approximation.

Introduction

In modern data science, we frequently encounter "tall" matrices where the number of observations $n$ far exceeds the number of features $d$. To make computations like least-squares regression, graph clustering, or principal component analysis (PCA) tractable, we often seek a spectral approximation: a much smaller matrix that preserves the essential geometric properties of the original data.

While offline and streaming algorithms have been developed to find these approximations, many real-world applications—such as sensor networks or high-frequency trading—require decisions to be made in real-time. This paper introduces the first rigorous algorithms for online row sampling. In this setting, an algorithm must decide immediately and irrevocably whether to store an incoming row or delete it forever. Unlike streaming models that allow for a "second pass" or a final pruning step, the online model requires the sketch to be valid at every time step with no opportunity to change previous decisions.

Methodology

The proposed algorithms are built upon the concept of leverage score sampling. A row's leverage score traditionally measures its influence relative to the entire matrix. Because the full matrix is unknown in an online setting, the authors utilize online ridge leverage scores.

1. Online-Sample

As each row $a_i$ arrives, the algorithm calculates its leverage score relative to the rows already stored in the approximation, plus a small regularization term ($\lambda I$). If the score is high—indicating the row provides novel information not yet captured by the current sketch—the row is kept with high probability. This approach ensures that the approximation grows only when necessary to maintain spectral accuracy.

2. Slim-Sample

To minimize memory overhead, the Slim-Sample variant avoids using the full current approximation to calculate scores. Instead, it maintains a "sketch of the sketch"—a compressed version of the previously selected rows. This allows the algorithm to estimate the importance of incoming rows while using significantly less working memory, which is particularly beneficial for graph sparsification.

3. Online-BSS

For scenarios where minimizing the final sample size is the priority, the authors present Online-BSS. This is a randomized adaptation of the Batson-Spielman-Srivastava (BSS) method. While it requires $O(d^2)$ memory to track the matrix properties, it reduces the final row count by a logarithmic factor, reaching the theoretical lower bound for online sampling.

Theoretical Insights

The Price of the Online Setting

A major contribution of this work is quantifying the "information cost" of the online constraint. The authors prove that online sampling is fundamentally more difficult than offline sampling. While offline methods can achieve approximations with $O(d \log d)$ rows, online methods must pay an additional factor proportional to the logarithm of the matrix's condition number, $\log(\kappa(A))$. This represents the inherent uncertainty of not knowing whether future rows will render current ones redundant.

Robustness Through Overestimation

A key technical insight is that the spectral approximation remains valid even if leverage scores are not calculated exactly, provided they are consistently overestimated. This property justifies the use of "sketches of sketches" in the Slim-Sample algorithm; as long as the importance of a row is not underestimated, the overall quality of the spectral approximation is preserved.

The Determinant Growth Argument

The proof for the sample size bound utilizes the Matrix Determinant Lemma. The authors demonstrate that every time a row is selected (due to a high leverage score), it significantly increases the determinant of the approximation's covariance matrix. Because the total determinant is bounded by the properties of the input matrix $A$, there is a strict limit on how many rows the algorithm can possibly select, providing a natural cap on the sample size.

Key Results and Complexity

  • Sample Efficiency: The Online-Sample algorithm produces an approximation with $O(\frac{d \log d \cdot \log(\epsilon \|A\|_2^2 / \delta)}{\epsilon^2})$ rows.
  • Optimality: The Online-BSS algorithm achieves $O(\frac{d \cdot \log(\epsilon \|A\|_2^2 / \delta)}{\epsilon^2})$ rows. The authors provide a lower-bound proof showing this is asymptotically optimal for any online algorithm.
  • Memory Efficiency: For graph Laplacian matrices, Slim-Sample can construct a spectral sparsifier using only $O(d \log^2 d)$ working memory, which is often less than the size of the final output.

Conclusion and Future Work

This work establishes the feasibility of high-quality spectral approximation in a strictly online environment. While the authors have identified a trade-off between memory usage ($O(d^2)$) and optimal sample size, finding an algorithm that is optimal in both remains an open question. Additionally, the techniques developed here for row sampling may have broader applications in online low-rank approximation and column subset selection, providing a foundation for more complex online dimensionality reduction tasks.

Summary updated

BibTeX
@inproceedings{cohen2016online,
  author = {Michael B. Cohen and Cameron Musco and Jakub Pachocki},
  title = {{Online Row Sampling}},
  booktitle = {APPROX-RANDOM},
  year = {2016},
  url = {https://openreview.net/forum?id=bzwe8S4feU3},
}
Figure