PhysSandbox
Classical MechanicsWaves & SoundElectricity & MagnetismOptics & LightGravity & OrbitsLabs
🌙Astronomy & The Sky🌡️Thermodynamics🌍Biophysics, Fluids & Geoscience📐Math Visualization🔧Engineering🧪Chemistry

More from Math Visualization

Other simulators in this category — or see all 52.

View category →
NewUniversity / research

DCT & JPEG Quantization (8×8)

64×64 luma: 8×8 DCT with −128 shift, ISO luminance quant table scaled by JPEG quality, or zigzag AC truncation (keep K). Click a block for coefficient heatmaps and zigzag trace.

Launch Simulator
NewUniversity / research

PLL (Phase-Locked Loop)

Discrete-time analog-style PLL: multiplier PD e = K_d sin(φ_ref − φ_VCO), PI loop filter, VCO ω = ω_fr + K_v u; step ω_ref to explore lock, capture, and steady-state phase error.

Launch Simulator
NewUniversity / research

ΔΣ (1-bit) Modulator

First- and second-order discrete-time ΔΣ with ±1 quantizer: shaped quantization noise, sine test tone, boxcar reconstruction, and Hann-windowed error spectrum (last 1024 samples).

Launch Simulator
NewUniversity / research

Polyphase L/M Resampling

Zero-stuff by L, Hamming-windowed sinc FIR at the high rate with min(π/L,π/M) cutoff, then decimate by M; spectra in/out and Noble-identity polyphase intuition.

Launch Simulator
NewUniversity / research

Mandelbrot Deep Zoom

Drag/wheel deep zoom into the Mandelbrot set with smooth continuous coloring and named landmarks.

Launch Simulator
NewUniversity / research

Julia Set Explorer

Pick c by clicking the embedded mini-Mandelbrot or animate c along a circle; Fatou dust vs connected sets.

Launch Simulator
PhysSandbox

Interactive physics, chemistry, and engineering simulators for students, teachers, and curious minds.

Physics

  • Classical Mechanics
  • Waves & Sound
  • Electricity & Magnetism

Science

  • Optics & Light
  • Gravity & Orbits
  • Astronomy & The Sky

More

  • Thermodynamics
  • Biophysics, Fluids & Geoscience
  • Math Visualization
  • Engineering
  • Chemistry

© 2026 PhysSandbox. Free interactive science simulators.

PrivacyTermsContact
Home/Math Visualization/LMS / NLMS Adaptive Noise Cancellation

LMS / NLMS Adaptive Noise Cancellation

This page simulates a textbook feedforward active noise control (ANC) path: the primary sensor records p[n] = s[n] + v[n], where s is a deterministic desired signal (sine, two tones, or a linear chirp) and v is interference generated by passing white Gaussian reference noise x[n] through a fixed unknown FIR h of length L_h (random coefficients each time you press “new noise path”). An L-tap adaptive FIR forms ŷ[n] = Σ_j w_j x[n−j] and the error e[n] = p[n] − ŷ[n] drives the Widrow–Hoff LMS update w ← w + μ e[n] x_n, where x_n is the tap-delay vector of reference samples. Normalized LMS (NLMS) divides the step by ε + ‖x_n‖², which stabilizes adaptation when the reference power swings. With L ≥ L_h and a small enough step, w converges toward the true h (up to delay ambiguity) so ŷ tracks v and e tracks s — the same algebra used to explain adaptive line enhancers, echo cancellation training, and simplified headphone ANC, modulo causality and secondary paths in real hardware.

Who it's for: Undergraduate signals & systems or adaptive DSP courses; anyone comparing Kalman filtering (state model) with stochastic-gradient adaptive FIRs (reference regression).

Key terms

  • LMS adaptive filter
  • NLMS
  • Widrow–Hoff
  • noise cancellation
  • FIR identification
  • mean-square error
  • tap-delay line
  • step-size μ

Live graphs

Adaptive FIR

Desired signal s[n]

32
12
-1.2
0.85

Measured values

RMSE(e − s)0.2096
RMSE(p − s) raw primary0.8717
Improvement p vs e4.16×
‖w − h‖ (final)0.0895
Lh used (≤ L)12

How it works

Feedforward noise cancellation with an FIR adaptive filter. The primary microphone picks up p[n] = s[n] + v[n] where s is the desired signal and v is interference built as a fixed unknown FIR of a reference noise x[n] (white Gaussian here). The filter forms ŷ[n] = wᵀxₙ with xₙ = [x[n], x[n−1], …, x[n−L+1]]ᵀ and minimizes e[n] = p[n] − ŷ[n] online using the LMS update w ← w + μ e[n] xₙ (or NLMS with μ / (ε + ‖xₙ‖²) for gentler scaling). When L is large enough and x spans the noise subspace, ŷ → v so e → s — classic adaptive DSP homework made visual.

Key equations

ŷ[n] = Σⱼ wⱼ x[n−j], e[n] = p[n] − ŷ[n]
LMS: w ← w + μ e[n] xₙ
NLMS: w ← w + (μ / (ε + ‖xₙ‖²)) e[n] xₙ

Frequently asked questions

Why is e[n] plotted as the “cleaned” output?
In this feedforward arrangement the adaptive filter is trying to copy the noise component v that is correlated with the reference x. When ŷ ≈ v, subtracting it from the primary leaves e = p − ŷ ≈ s + v − v = s. So the error node is exactly where you would listen after cancellation.
When does LMS diverge or oscillate?
For standard LMS on FIR systems, the classic upper bound is 0 < μ < 2 / λ_max(R_xx) where R_xx is the tap-input autocorrelation matrix. Too large μ grows the eigenmodes of the weight-error recursion until the adaptation blows up — try the “LMS too large μ” preset with NLMS turned off. NLMS rescales μ by instantaneous input energy, which usually widens the stable range.
What if L is smaller than the true noise path length L_h?
The adaptive FIR only has L degrees of freedom. If the physical coupling needs more taps, the residual v − ŷ stays correlated with x and e still contains noise. Increase L until the misalignment ‖w − h‖ stops improving for a fixed random path.
How is this different from the Kalman filter simulator?
Kalman filtering assumes an explicit dynamical model for the hidden state and Gaussian noise covariances; the gain matrix comes from solving Riccati-style recursions. LMS is a stochastic-gradient descent on the instantaneous squared error with respect to FIR weights — no explicit state transition matrix, but also no optimality guarantee under non-Gaussian or nonstationary statistics.