RLS Filter for PPG Motion Artifact Cancellation
**The Recursive Least Squares (RLS) algorithm represents the gold standard for adaptive PPG motion artifact cancellation when convergence speed matter...
- PPG & Signal Processing

The Recursive Least Squares (RLS) algorithm represents the gold standard for adaptive PPG motion artifact cancellation when convergence speed matters more than computational cost. Where the LMS and NLMS algorithms estimate filter weights using stochastic gradient descent, RLS directly solves the least squares optimization at each time step using recursive matrix inversion. The result is dramatically faster convergence, particularly during the rapid motion transitions that challenge simpler adaptive filters.
This article provides a complete technical treatment of RLS for PPG signal processing, including the mathematical derivation, forgetting factor analysis, computational cost breakdown, practical implementation guidance, and published benchmark results. For context on how RLS fits within the broader landscape of PPG motion artifact removal, see our comprehensive artifact removal guide.
Mathematical Foundation
The Deterministic Least Squares Problem
RLS minimizes a weighted least squares cost function over all data observed up to time :
where is the forgetting factor () and is the prediction error using the current weight vector applied to the reference input . The exponential weighting assigns decreasing importance to older data, allowing the filter to track non-stationary statistics.
Setting the gradient of to zero yields the normal equations:
where is the weighted autocorrelation matrix and is the weighted cross-correlation vector. The optimal weight vector is .
Recursive Update Derivation
Direct inversion of at each time step would require operations, making it impractical. The RLS algorithm avoids this by recursively updating the inverse matrix using the matrix inversion lemma (Woodbury identity):
where the Kalman gain vector is:
The complete RLS algorithm per sample is:
- Compute the a priori error:
- Compute the Kalman gain:
- Update the weight vector:
- Update the inverse correlation matrix:
The initialization is , where is a small positive constant (typically 0.01 to 1.0) and is the identity matrix. This corresponds to assuming large initial uncertainty about the filter weights.
The Forgetting Factor: PPG-Specific Analysis
The forgetting factor is the single most important tuning parameter for RLS in PPG applications. It controls the effective memory length of the algorithm:
This effective memory determines how quickly the filter adapts to changing motion statistics.
Forgetting Factor Selection for Different Activities
Scroll horizontally if needed
| Activity Type | Recommended | (at 100 Hz) | Rationale |
|---|---|---|---|
| Rest / seated | 0.998-0.999 | 500-1000 samples (5-10 s) | Stable motion; prioritize noise suppression |
| Steady walking | 0.995-0.998 | 200-500 samples (2-5 s) | Periodic motion; moderate adaptation needed |
| Running | 0.99-0.995 | 100-200 samples (1-2 s) | Higher motion variability |
| Activity transitions | 0.95-0.99 | 20-100 samples (0.2-1 s) | Rapid statistics change; fast tracking essential |
| Free-living / random motion | 0.98-0.99 | 50-100 samples (0.5-1 s) | Unpredictable motion changes |
Choosing too low (e.g., < 0.95) causes numerical instability as can grow unbounded when insufficient data is available to constrain the matrix. Choosing too high (e.g., > 0.999) during dynamic conditions causes the filter to lag behind motion changes, producing residual artifacts in the output.
Adaptive Forgetting Factor
A fixed forgetting factor cannot optimally serve all activity conditions. Several researchers have proposed adaptive forgetting factor schemes for PPG:
One approach is a variable forgetting factor that decreases during detected transitions and increases during steady-state periods, with transitions detected from the short-term variance of the accelerometer signal.
Another is gradient-based forgetting factor adaptation, where is updated to minimize the squared prediction error. This fully automatic approach eliminates the need for activity detection but adds computational overhead per sample.
Computational Complexity and Embedded Implementation
Operations Count
The standard RLS algorithm requires per sample:
- Kalman gain computation: multiplications, additions
- Weight update: multiplications, additions
- Matrix update: multiplications, additions
- Total: approximately multiply-accumulate operations
For comparison, LMS requires and NLMS requires operations per sample.
Scroll horizontally if needed
| Filter Order | LMS (ops) | NLMS (ops) | RLS (ops) | Ratio RLS/NLMS |
|---|---|---|---|---|
| 8 | 16 | 25 | 232 | 9.3x |
| 16 | 32 | 49 | 848 | 17.3x |
| 32 | 64 | 97 | 3,232 | 33.3x |
| 64 | 128 | 193 | 12,608 | 65.3x |
At and 100 Hz sample rate, RLS requires approximately 84,800 multiply-accumulate operations per second. An ARM Cortex-M4F running at 64 MHz with single-cycle MAC can execute approximately 64 million MACs per second, meaning RLS at consumes only 0.13% of the processor's capacity. This is well within the budget of modern wearable processors.
Numerical Stability Considerations
The standard RLS algorithm can suffer from numerical instability because the matrix must remain positive definite. Round-off errors, particularly in fixed-point implementations, can cause to lose positive definiteness and the algorithm to diverge.
Several strategies mitigate this:
Symmetry enforcement. After each update, force to maintain symmetry. This adds operations but prevents asymmetry-driven divergence.
Square-root RLS. Propagate the square root of (using Cholesky factorization) instead of directly. This guarantees positive definiteness at the cost of increased implementation complexity (Haykin, 2014).
QR-decomposition RLS. Use QR decomposition for the recursive update, which provides superior numerical properties and reduces complexity to with better conditioning. This is the recommended approach for fixed-point embedded implementations.
Periodic re-initialization. Reset to periodically (e.g., every 10-30 seconds) or when divergence is detected. While crude, this approach is simple and effective for many practical PPG applications.
Benchmark Results
IEEE Signal Processing Cup 2015 Dataset
The IEEE SP Cup 2015 dataset is the most widely used benchmark for PPG motion artifact removal. It contains wrist PPG and 3-axis accelerometer data from 12 subjects performing treadmill exercise at varying speeds (6-15 km/h) with simultaneous ECG ground truth.
On this dataset, Zhang et al.'s TROIKA framework (signal decomposition, sparse spectrum reconstruction, and spectral peak tracking) reported an average absolute heart rate error of 2.34 BPM, with a Pearson correlation of 0.992 against ECG (doi:10.1109/TBME.2014.2359372). Results like this show that the adaptive filter is usually only one stage of a competitive pipeline.
Free-Living Activity Data
Free-living data are a harder test than controlled treadmill exercise because motion is unpredictable and includes a wide variety of artifact types. In this setting, coverage (the percentage of time an algorithm produces a valid HR estimate) matters as much as error, because the algorithm must also decide when signal quality is too poor for a reliable estimate. RLS's fast reconvergence after brief motion episodes is an advantage here.
Multi-Wavelength PPG
With multi-wavelength PPG (for example, green plus infrared), an additional wavelength channel can serve as a secondary noise reference alongside the accelerometer, because motion artifacts affect different wavelengths differently due to wavelength-dependent tissue scattering. RLS extends naturally to multiple reference channels. For more on multi-wavelength PPG design, see our green vs. red vs. infrared PPG guide.
Fast RLS Variants for Resource-Constrained Devices
When the cost of standard RLS is prohibitive, several fast variants reduce complexity while preserving much of the convergence advantage:
Lattice RLS
The lattice RLS algorithm decomposes the filtering operation into a lattice structure of first-order sections, reducing per-sample complexity to . The algorithm maintains forward and backward prediction errors that propagate through the lattice stages. For PPG, lattice RLS at requires approximately 200 operations per sample (compared to 3,232 for standard RLS).
Sliding-Window RLS
Rather than using exponential forgetting, sliding-window RLS uses a finite window of the most recent samples. This bounds the memory requirements and provides exact exponential-order convergence within the window. For PPG at 100 Hz with (2-second window), computational cost remains but numerical stability is improved because the matrix condition is bounded by the window length.
Dichotomous Coordinate Descent RLS (DCD-RLS)
DCD-RLS replaces the matrix inversion step with an iterative coordinate descent solver that terminates after a fixed number of iterations (typically 4-8). This reduces worst-case complexity to where K is the number of iterations, and avoids the matrix storage requirement entirely by reconstructing the autocorrelation matrix on the fly. DCD-RLS was introduced by Zakharov et al. (2008) as a family of low-complexity RLS algorithms (doi:10.1109/TSP.2008.917874).
Integration in Multi-Stage Pipelines
In practice, RLS is rarely used in isolation for PPG heart rate estimation. Modern pipelines combine RLS with additional processing stages for optimal performance:
Stage 1: Pre-processing. Bandpass filtering (0.4-5 Hz, 4th-order Butterworth) and DC removal on both PPG and accelerometer signals. Normalization to unit variance.
Stage 2: RLS adaptive filtering. Motion artifact cancellation using the accelerometer reference. This produces an initial estimate of the clean cardiac signal.
Stage 3: Spectral analysis. Short-time FFT (window 6-10 seconds, overlap 1-2 seconds) or multiple signal classification (MUSIC) to identify the dominant cardiac frequency.
Stage 4: Spectral peak tracking. Viterbi-style dynamic programming or Kalman filtering to track the cardiac frequency across time, exploiting continuity constraints and harmonic structure.
Stage 5: Validation. Signal quality index (SQI) computation to flag unreliable segments. Physiological bounding (30-220 BPM, maximum rate of change 10 BPM/s).
Zhang et al. (2015) showed with TROIKA that combining denoising with sparse signal reconstruction and spectral peak tracking (Stages 3-4) achieved an average absolute error of 2.34 BPM on 12 subjects running at up to 15 km/h (doi:10.1109/TBME.2014.2359372). A cleaner Stage 2 output benefits every downstream stage.
For a deeper exploration of how these pipeline stages interconnect, visit our PPG signal processing algorithms page and our conditions-specific monitoring guides.
RLS vs. Deep Learning Approaches
The emergence of deep learning for PPG denoising raises the question of whether RLS remains relevant. Current evidence suggests complementary roles:
Deep learning methods (CNN, LSTM, U-Net architectures) trained on large datasets can achieve lower error than RLS on within-distribution test data. Reiss et al. (2019) introduced the large PPG-DaLiA dataset and a CNN that takes time-frequency spectra of PPG and accelerometer signals as input; on large datasets it significantly outperformed classical methods, reducing mean absolute error by 31% on PPG-DaLiA and 21% on WESAD (doi:10.3390/s19143079).
However, deep learning models require substantial training data, are opaque in their failure modes, and may not generalize across sensor hardware, population demographics, or activity types not represented in training. RLS requires no training data, has well-understood failure modes, and adapts to any motion type at deployment time.
A pragmatic architecture uses RLS for initial denoising and a lightweight neural network for refinement and spectral estimation. This combines the guaranteed stability and adaptability of RLS with the pattern recognition strengths of deep learning.
Conclusion
RLS adaptive filtering provides the fastest convergence and highest accuracy among classical adaptive filters for PPG motion artifact cancellation. Its computational cost, once considered prohibitive for wearable devices, is easily handled by modern embedded processors for practical filter orders. The forgetting factor provides a single, interpretable tuning parameter that controls the balance between tracking speed and noise suppression.
For applications requiring the best possible heart rate estimation accuracy during dynamic motion, RLS should be the default adaptive filter choice. When combined with spectral tracking in a multi-stage pipeline, adaptive filtering contributes to systems that reach errors of a few BPM on standard exercise benchmarks.
Explore our companion articles on LMS/NLMS filtering for lower-complexity alternatives, ICA for multi-channel PPG for reference-free approaches, and our complete algorithms reference for implementation guidance.
References
- Haykin, S. (2014). Adaptive Filter Theory (5th ed.). Pearson.
- Zakharov, Y. V., White, G. P., & Liu, J. (2008). Low-complexity RLS algorithms using dichotomous coordinate descent iterations. IEEE Transactions on Signal Processing, 56(7), 3150-3161. https://doi.org/10.1109/TSP.2008.917874
- Zhang, Z., Pi, Z., & Liu, B. (2015). TROIKA: A general framework for heart rate monitoring using wrist-type photoplethysmographic signals during intensive physical exercise. IEEE Transactions on Biomedical Engineering, 62(2), 522-531. https://doi.org/10.1109/TBME.2014.2359372
- Reiss, A., Indlekofer, I., Schmidt, P., & Van Laerhoven, K. (2019). Deep PPG: Large-scale heart rate estimation with convolutional neural networks. Sensors, 19(14), 3079. https://doi.org/10.3390/s19143079
Related articles
Kalman Filter for PPG Motion Artifact Suppression
Kalman filtering gives PPG engineers a principled way to suppress motion artifact by modeling pulse dynamics, sensor noise, and motion disturbance as time-varying states rather than treating filtering as a fixed one-size-fits-all step.
Motion Artifact Detection in PPG: How to Flag Bad Windows Before Estimation
Practical methods for motion artifact detection in PPG using signal quality indices, accelerometer fusion, spectral tests, and reject-or-repair rules.
PPG Motion Artifact Removal: Algorithms, Methods & Implementation Guide
A comprehensive technical guide to PPG motion artifact removal covering adaptive filtering (LMS, RLS, NLMS), ICA, EMD, wavelet decomposition, SVD, and deep learning methods. Includes algorithm comparison, pipeline design, benchmark datasets, and real-time implementation considerations.
PPG vs ECG for HRV: How Motion Artifacts Affect Heart Rate Variability Accuracy
PPG-based HRV is accurate enough for resting measurements but degrades significantly with movement. The difference compared to ECG gold-standard measu...
PPG Butterworth Filter Design
Butterworth filters are the default choice for PPG signal conditioning because they offer a maximally flat passband with no ripple, which preserves th...
