---
title: Ramanujan Subspace Pursuit (RSP)
url: https://www.emergentmind.com/topics/ramanujan-subspace-pursuit-rsp
type: topic
---

# Ramanujan Subspace Pursuit (RSP)

The Ramanujan Subspace Pursuit (RSP) is a greedy iterative signal decomposition algorithm that uniquely represents any finite-length signal as a sum of exactly periodic components. RSP operates by sequentially identifying and subtracting the most energetic exactly-periodic structure at each step, leveraging orthogonal projections into a hierarchy of Ramanujan subspaces. The algorithm’s backbone is an explicit construction of these subspaces using Ramanujan sums, which enable the discovery of both overt and latent integer periodicities regardless of signal length or divisibility. This methodology, along with its computationally optimized fast variant (FRSP), provides precise, robust decomposition and period estimation capabilities for applications in signal processing, sequence analysis, and beyond [1512.08112].

## 1. Ramanujan Subspaces: Construction and Properties

For integer period $q$, the Ramanujan sum $c_q(n)$ is defined as:
$$
c_q(n) = \sum_{\substack{1\leq k \leq q \\ \gcd(k,q)=1}} e^{j2\pi k n/q}
$$
These sums are $q$-periodic in $n$. The circulant Ramanujan matrix $\mathbf{B}_q \in \mathbb{R}^{q \times q}$ embeds these sums:
$$
\mathbf{B}_q =
\begin{pmatrix}
c_q(0) & c_q(q-1) & \cdots & c_q(1) \\
c_q(1) & c_q(0)   & \cdots & c_q(2) \\
\vdots & \vdots   & \ddots & \vdots \\
c_q(q-1) & c_q(q-2) & \cdots & c_q(0)
\end{pmatrix}
$$
The Ramanujan subspace $\mathcal{S}_q$ is the range of $\mathbf{B}_q$, with dimension equal to Euler’s totient $\phi(q)$. Every element $\mathbf{s}\in\mathcal{S}_q$ is exactly $q$-periodic and not periodic for any $d<q$. The orthogonal projector onto $\mathcal{S}_q$ is $\mathbf{P}_q = q^{-1} \mathbf{B}_q$, satisfying $\mathbf{P}_q^2 = \mathbf{P}_q$ and $\mathbf{P}_q^T = \mathbf{P}_q$, with the projection operation given by $\operatorname{Proj}(\mathbf{x}, \mathcal{S}_q) = \mathbf{P}_q \mathbf{x}$ for $\mathbf{x}\in\mathbb{R}^q$.

## 2. Periodicity Metric and Energy Quantification

Given $\mathbf{x} \in \mathbb{R}^N$ and a candidate period $q \leq Q$, one extends projection into $\mathcal{S}_q$ over the entire signal (using zero-padding or block-averaging as needed). Define the projected signal $\mathbf{x}_q = \operatorname{Proj}(\mathbf{x}, \mathcal{S}_q)$, and compute its sample autocorrelation:
$$
\varphi_{\mathbf{x}_q}(k) = \sum_{n=1}^{N-k} x_q(n) x_q(n+k), \quad 0 \leq k < N
$$
The periodicity metric is
$$
P(\mathbf{x}_q, q) = \sum_{l=0}^{M-1} \varphi_{\mathbf{x}_q}(lq), \quad M = \left\lceil \frac{N}{q} \right\rceil
$$
Analysis yields
$$
P(\mathbf{x}_q, q) = \frac{N+q}{2q} \|\mathbf{x}_q\|^2
$$
For $N \gg q$,
$$
P(\mathbf{x}_q, q) \approx \frac{1}{2q} \|\mathbf{x}_q\|^2
$$
This metric allows the identification and ordering of dominant periodicities within a signal.

## 3. Greedy Decomposition: The RSP Algorithm

RSP decomposes a signal $\mathbf{x}$ by iteratively projecting the residual into all exactly-periodic Ramanujan subspaces and extracting the component whose periodicity metric is maximized. At iteration $k$ (starting with $\mathbf{r}^0=\mathbf{x}$):

1. For each $q \in [1, Q]$:
    - Compute $\mathbf{x}_q^{(k)} = \operatorname{Proj}(\mathbf{r}^{k-1}, \mathcal{S}_q)$.
    - Compute $P(\mathbf{x}_q^{(k)}, q)$.

2. Select $q_k = \arg\max_{q} P(\mathbf{x}_q^{(k)}, q)$.

3. Update the residual: $\mathbf{r}^k = \mathbf{r}^{k-1} - \mathbf{x}_{q_k}^{(k)}$.

After $K$ steps:
$$
\mathbf{x} = \sum_{k=1}^{K} \mathbf{x}_{q_k}^{(k)} + \mathbf{r}^K
$$
with energy conservation $\|\mathbf{r}^k\|^2 = \|\mathbf{r}^{k-1}\|^2 - \|\mathbf{x}_{q_k}^{(k)}\|^2$. In the limit $K\to\infty$, $\mathbf{r}^K\to 0$, yielding a unique orthogonal sum of exactly-periodic components.

## 4. Computational Complexity and Fast RSP (FRSP)

Naïve RSP requires $O(QN^2)$ operations per iteration, due to $Q$ projections (each $O(N^2)$) per step. Fast RSP circumvents direct projection by exploiting the structure of periodic subspaces:
$$
\mathcal{P}_q = \bigoplus_{d|q} \mathcal{S}_d, \qquad \|\check{\mathbf{x}}_q\|^2 = \sum_{d|q} \|\mathbf{x}_d\|^2
$$
Here, $\mathcal{P}_q$ is the space of all $q$-periodic signals, and $\check{\mathbf{x}}_q$ is the projection into $\mathcal{P}_q$. By maximum likelihood estimation,
$$
\|\check{\mathbf{x}}_q\|^2 = \frac{q}{N}\left( \varphi_{\mathbf{x}}(0) + 2 \sum_{l=1}^{\lfloor N/q \rfloor} \varphi_{\mathbf{x}}(lq) \right)
$$
$\|\mathbf{x}_q\|^2$ is computed by subtracting projections onto proper divisors of $q$. If the autocorrelation is calculated via FFT methods ($O(N \log N)$), the total per-iteration complexity becomes $O(N \log N)$, yielding $O(K N \log N)$ overall.

## 5. Comparative Performance Across Period Estimation Methods

Experimental evaluations on synthetic $\sum_i\cos(2\pi n/q_i)$ signals reveal that Ramanujan Periodicity Transforms (RPT) and Even-Period Synchronous Detection (EPSD) are limited to cases where period $q_i$ divides length $N$. Classical periodicity transforms (Small2Large, BestCorrelation, BestFrequency, Mbest) often miss true periods or yield spurious ones, particularly at low SNR or when $q_i \nmid N$. In contrast, RSP and FRSP identify all integer and non-integer periods, are robust to additive noise down to SNR $\approx 0$ dB, and show accuracy $\gtrsim 0.8$ (Hellinger-based periodic similarity) at $0$ dB, surpassing all compared methods [1512.08112]. This suggests superior adaptability and reliability for complex, noisy, or non-ideal data scenarios.

## 6. Applications and Spectral Interpretation

RSP/FRSP is applicable to any context requiring the extraction of hidden, overt, or integer-valued periodicities, including but not limited to:

- Biomolecular sequence analysis (e.g., latent repeats in DNA/protein)
- Speech signal pitch and sub-harmonic estimation
- Music rhythm and beat tracking
- Mechanical vibration and fault diagnosis (e.g., gear-tooth periodicities)
- General signal denoising and periodic feature extraction

In practical data analysis, these algorithms yield both an exact decomposition into orthogonal exactly-periodic signals and a spectral description via the Periodic Energy Spectrum (PES):
$$
\mathrm{PES}(q) = \|\mathbf{x}_q\|^2, \quad q=1, \ldots, Q
$$
A plausible implication is that RSP/FRSP provides insight analogous to frequency spectra, but resolves fine integer-structured periodicities that may be hidden from classical spectral transforms.

Source: https://www.emergentmind.com/topics/ramanujan-subspace-pursuit-rsp