Initializing playground…
← Back to roadmap

🎛️ Digital Filters — Interactive Playground

FIR and IIR filter design and application — mirrors scipy.signal.
Edit any code block below and press ▶ Run (or Ctrl+Enter) to execute it live in your browser.

1. Low-pass FIR with firwin

Design a 51-tap Hamming-windowed low-pass FIR and check its DC and Nyquist gain.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

2. High-pass FIR

Pass high frequencies by setting pass_zero: false. DC gain should be near 0, Nyquist near 1.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

3. Apply FIR: lfilter vs filtfilt

lfilter is causal (has phase delay); filtfilt applies the filter twice for zero-phase output.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

4. Butterworth low-pass filter design

Design a 4th-order Butterworth IIR filter. butter returns both SOS form (numerically preferred) and ba form.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

5. Apply Butterworth: sosfilt vs sosfiltfilt

Filter a noisy 50 Hz signal to remove 300 Hz interference. Zero-phase output is closer to the clean reference.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

6. High-pass Butterworth

A 2nd-order Butterworth high-pass attenuates DC and passes high frequencies.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

7. Butterworth gain at cutoff — multiple orders

All Butterworth filters have exactly −3 dB gain at the cutoff frequency, regardless of order.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

API Reference

FunctionDescriptionMirrors
firwin(n, cutoff, opts?)FIR design (windowed-sinc)scipy.signal.firwin
butter(N, Wn, type?)Butterworth IIR designscipy.signal.butter
freqz(b, a?, worN?)FIR/IIR frequency responsescipy.signal.freqz
sosfreqz(sos, worN?)SOS frequency responsescipy.signal.sosfreqz
lfilter(b, a, x)Causal FIR/IIR filterscipy.signal.lfilter
filtfilt(b, a, x)Zero-phase filterscipy.signal.filtfilt
sosfilt(sos, x)Causal SOS filterscipy.signal.sosfilt
sosfiltfilt(sos, x)Zero-phase SOS filterscipy.signal.sosfiltfilt