How low-pass, high-pass, band-pass, and band-stop filters retain certain frequencies and reject others — Butterworth, Chebyshev, elliptic, Bessel, and FIR designs; cutoff frequency and filter order; and why zero-phase filtering eliminates phase lag.

Contents
  1. What Is a Digital Filter? Which Frequencies Stay in My Signal?
  2. Filter Types: Low-Pass, High-Pass, Band-Pass, and Band-Stop
  3. Methods
    1. Butterworth
    2. Chebyshev Type I
    3. Chebyshev Type II
    4. Elliptic
    5. Bessel
    6. FIR (Window Method)
  4. Which One Should You Choose?
  5. Key Ideas
    1. Cutoff and Order: The −3 dB Point and the Roll-Off
    2. Phase Lag: Why Zero-Phase Filtering Needs the Whole Record
    3. The Moving Average Is a Low-Pass Filter, a Poor One
    4. Ripple Against Sharpness
    5. Edges: The Start-Up Transient
    6. Nyquist: A Filter Cannot Undo Aliasing
  6. REFs

What Is a Digital Filter? Which Frequencies Stay in My Signal?

A measured signal is usually a mixture of different components. An electrocardiogram (ECG) may contain 50 Hz or 60 Hz power-line hum, an accelerometer may pick up motor vibrations on top of the slow motion you want to measure, and every sensor adds broadband noise. When the wanted and unwanted components occupy different frequency ranges, they can be separated.

A digital filter does exactly that with sampled data: it preserves the frequencies you want and attenuates the rest (Fig 1).

On the left a slow wave covered in fast 50 Hz wiggles and noise; an arrow labelled low-pass, cutoff 10 Hz; on the right the same slow wave, clean

Fig 1. A low-pass filter keeps the slow wave and removes the hum and the noise

Every filter on this page computes each output sample $y[n]$ from the current and past input samples $x[n], x[n-1], \dots$ and, for most designs, from past output samples as well. The coefficients $b_k$ and $a_k$ are chosen by the filter design method (Math 1).

$$y[n] = \sum_{k=0}^{2} b_k\, x[n-k] - \sum_{k=1}^{2} a_k\, y[n-k] = b_0 x[n] + b_1 x[n-1] + b_2 x[n-2] - a_1 y[n-1] - a_2 y[n-2]$$
$$\begin{aligned} y[n] &= \sum_{k=0}^{2} b_k\, x[n-k] - \sum_{k=1}^{2} a_k\, y[n-k] \\ &= b_0 x[n] + b_1 x[n-1] + b_2 x[n-2] \\ &\quad - a_1 y[n-1] - a_2 y[n-2] \end{aligned}$$

Math 1.

Math 1 represents one second-order section (SOS). A higher-order filter can be implemented as a chain of such sections, with each section feeding the next. For example, an order-4 filter consists of two second-order sections.

A filter is described by its frequency response: when a sine wave at frequency $f$ is applied as input, the output is a sine wave at the same frequency, scaled by the gain $G(f)$. A gain of 1 leaves that frequency unchanged, while a gain near 0 suppresses it. Gain is often expressed in decibels (dB) as $20 \log_{10} G$. Thus, $-20$ dB corresponds to one-tenth of the original amplitude, while $-60$ dB corresponds to one-thousandth.

A digital filter is not the same as smoothing. Smoothing is typically controlled by a window size measured in data points and often assessed visually; it primarily suppresses rapid variations. A filter, by contrast, is specified by a cutoff frequency in hertz. It can preserve slow variations, fast variations, or a band of frequencies in between. Its frequency response characterizes how each frequency is affected.

A filter is not the same as detrending, either. A high-pass filter attenuates frequencies below its cutoff, whereas detrending subtracts an estimated baseline from the signal.

Consider an example: a slow 2 Hz sine wave with an amplitude of 1, a 50 Hz hum with an amplitude of 0.5, and a small amount of random noise. The signal is sampled at 250 samples per second for 2 seconds, producing 500 data points (Table 1).

t (s)y (measured)2 Hz signal50 Hz hum
0.0000.00010.00000.0000
0.0040.55560.05020.4755
0.0080.36680.10040.2939
0.012−0.23270.1502−0.2939
0.016−0.32130.1997−0.4755
0.1241.42770.99990.4755
0.2480.33170.02510.2939
0.5000.03630.00000.0000
1.000−0.32510.00000.0000
1.996−0.6336−0.0502−0.4755

Table 1. The example: 10 of its 500 points, with the two tones that make each one

The hum repeats every 5 samples, so it swings from 0 to ±0.48 within a few rows. The bold row is near the top of the slow wave, where the hum adds 0.48 on top of it. Chart 1 plots all 500 points.

500 measured points spread in a band about 1 wide around a slow 2 Hz sine, drawn dashed in red

Chart 1. The example: measured data and the 2 Hz signal inside it

The task: recover the dashed 2 Hz wave from the data points.

Filter Types: Low-Pass, High-Pass, Band-Pass, and Band-Stop

The filter type determines which frequencies a filter preserves and which it attenuates (Fig 2):

Four panels of gain against frequency from 0 to 125 Hz: low-pass at 1 up to 10 Hz then falling to 0; high-pass rising from 0 to 1 around 20 Hz; band-pass a plateau from 40 to 60 Hz; band-stop at 1 everywhere except a narrow dip to 0 at 50 Hz

Fig 2. The four types, each a Butterworth filter of order 4

The frequency range extends up to 125 Hz, half the sampling rate. This limit, called the Nyquist frequency, is the highest frequency that can be uniquely represented by sampled data (see Nyquist).

Methods

Six filter designs, each representing a different trade-off between passband flatness, transition steepness, and time-domain behavior. For a fair comparison, all six methods are applied to the example using a low-pass filter with a cutoff frequency of 10 Hz and an order of 4. The FIR filter uses 101 taps.

Butterworth

In plain words. The flattest possible passband: the gain stays at 1 as long as possible, then falls smoothly through the cutoff, with no ripple anywhere.

Control parameters. order ($n$, below) determines how steeply the gain falls; cutoff ($f_c$) is the frequency at which the gain has dropped to $1/\sqrt{2}$, or −3 dB.

Basic idea. The digital Butterworth filter has a closed-form gain expression that depends on the sampling rate $f_s$ (Math 2).

$$G(f) = \frac{1}{\sqrt{1 + \left(\dfrac{\tan(\pi f / f_s)}{\tan(\pi f_c / f_s)}\right)^{2n}}}$$

Math 2.

Example. How much of the 50 Hz hum survives a cutoff of 10 Hz at order 4, with $f_s = 250$ Hz? First, calculate the ratio inside the brackets (Math 3).

$$\frac{\tan(\pi \cdot 50 / 250)}{\tan(\pi \cdot 10 / 250)} = \frac{0.72654}{0.12633} = 5.7512$$

Math 3.

Then raise it to the power $2n = 8$ (Math 4).

$$G(50) = \frac{1}{\sqrt{1 + 5.7512^{8}}} = \frac{1}{\sqrt{1 + 1.197 \times 10^{6}}} = 0.000914 \;\; (-60.8 \text{ dB})$$

Math 4.

The hum's amplitude of 0.5 is reduced to 0.00046. At 2 Hz, the same formula gives a gain of 0.999999, so the slow wave passes essentially untouched.

Important characteristics. Monotonic: the gain only decreases as frequency increases, both within the passband and beyond the cutoff. It is the default choice when nothing else is known.

Advantages

Disadvantages

Chebyshev Type I

In plain words. Allow the passband gain to ripple slightly, and in return, the gain falls faster beyond the cutoff.

Control parameters. order ($n$); ripple ($r_p$, in dB), the maximum ripple allowed in the passband; and cutoff ($f_c$), the frequency at which the gain reaches the lower edge of the ripple band for the last time.

Basic idea. The Chebyshev filter replaces Butterworth's power term with a Chebyshev polynomial $T_n$, which oscillates between −1 and 1 in the passband. Here, $\Omega = \tan(\pi f / f_s)$ is the prewarped frequency used in Math 2 (Math 5).

$$G(f) = \frac{1}{\sqrt{1 + \varepsilon^2\, T_n^2(\Omega / \Omega_c)}}, \qquad \varepsilon = \sqrt{10^{\,r_p/10} - 1}$$

Math 5.

Example. With $r_p = 1$ dB (Math 6):

$$\varepsilon = \sqrt{10^{0.1} - 1} = 0.5088, \qquad G_{\min} = \frac{1}{\sqrt{1 + \varepsilon^2}} = 0.8913$$

Math 6.

Every passband frequency has a gain between 0.8913 and 1. For even-order filters, the gain at 0 Hz is at the bottom of this range, so a constant signal is reduced to 89.13% of its original level.

Important characteristics. Steeper than Butterworth at the same order: −72.7 dB at 50 Hz versus −60.8 dB.

Advantages

Disadvantages

Chebyshev Type II

In plain words. Keep the passband flat and put the ripple in the stopband instead, where the gain is already small.

Control parameters. order ($n$); attenuation ($r_s$, in dB), the minimum attenuation anywhere in the stopband; and cutoff ($f_c$), which here marks the start of the stopband rather than the end of the passband.

Basic idea. The inverse Chebyshev filter effectively inverts the Chebyshev polynomial (Math 7).

$$G(f) = \frac{1}{\sqrt{1 + \dfrac{1}{\varepsilon^2\, T_n^2(\Omega_c / \Omega)}}}, \qquad \varepsilon = \frac{1}{\sqrt{10^{\,r_s/10} - 1}}$$

Math 7.

Example. With $r_s = 40$ dB, the maximum gain in the stopband is $10^{-40/20} = 0.0100$, and $\varepsilon = 0.0100$. Because 10 Hz is already in the stopband, the passband ends at a lower frequency: the gain falls to −3 dB at 4.99 Hz (Chart 2).

Important characteristics. A flat passband, like Butterworth, combined with a steep transition, like Chebyshev Type I; the trade-off is a finite stopband floor.

Advantages

Disadvantages

Elliptic

In plain words. Allow ripple in both bands in return for the steepest transition of any filter of a given order.

Control parameters. order ($n$); ripple ($r_p$); attenuation ($r_s$); and cutoff ($f_c$), the passband edge, as in Chebyshev Type I.

Basic idea. The elliptic (Cauer) filter uses an elliptic rational function $R_n$, which oscillates in both the passband and the stopband (Math 8).

$$G(f) = \frac{1}{\sqrt{1 + \varepsilon^2\, R_n^2(\Omega / \Omega_c)}}$$

Math 8.

Example. With $r_p = 1$ dB and $r_s = 40$ dB, the gain stays between 0.8913 and 1 up to 10 Hz, then reaches −40 dB at about 15 Hz—the narrowest transition in Chart 2.

Important characteristics. Optimal in one sense only: it provides the narrowest transition for a given order and ripple specification. The trade-off is ripple in both bands and a less clean step response.

Advantages

Disadvantages

Bessel

In plain words. Give up a sharp edge to preserve the shape of the signal: every frequency in the passband is delayed by nearly the same amount, so a pulse comes out looking like a pulse.

Control parameters. order ($n$); cutoff ($f_c$), set here as the −3 dB point, the same as for Butterworth.

Basic idea. The Bessel filter is built from a reverse Bessel polynomial $\theta_n$, chosen to make the group delay as flat as possible across the passband (Math 9).

$$H(s) = \frac{\theta_n(0)}{\theta_n(s / \omega_0)}$$

Math 9.

Example. The step response rises to 1 and overshoots by only 1.0% (Chart 3), but the gain at 50 Hz is just −46.7 dB.

Important characteristics. The gentlest transition of the six, and the cleanest time-domain response.

Advantages

Disadvantages

FIR (Window Method)

In plain words. Use no feedback at all: each output is a weighted sum of the last $M$ inputs, with weights obtained by truncating and windowing the ideal low-pass filter.

Control parameters. taps ($M$), the number of weights; window ($w_k$), the taper applied to them; and cutoff ($f_c$), where the gain is 0.5, or −6 dB—provided the transition is narrow compared with the cutoff. For a Hamming window, the transition width is roughly $3.3 f_s / M$.

Basic idea. A finite impulse response (FIR) filter starts with the ideal low-pass response—a sinc function—truncates it to $M$ samples around its center $K = (M-1)/2$, and tapers it with a window (Math 10).

$$h_k = w_k\, \frac{\sin\!\big(2\pi f_c (k - K) / f_s\big)}{\pi (k - K)}, \qquad y[n] = \sum_{k=0}^{M-1} h_k\, x[n-k] = h_0 x[n] + h_1 x[n-1] + \dots + h_{M-1} x[n-M+1]$$

Math 10.

Example. With $M = 101$ taps and a Hamming window, the center weight is $h_{50} = 0.08020$, close to the unwindowed value $2 f_c / f_s = 0.08000$. The response is symmetric about $K = 50$, so every frequency is delayed by exactly $K / f_s = 200$ ms.

Important characteristics. Always stable, with exactly linear phase: a pure delay that is the same for every frequency.

Advantages

Disadvantages

Which One Should You Choose?

Chart 2 overlays the six gains in decibels. Chart 3 shows how each filter responds to a sudden step, and Table 2 summarizes both, together with the error each filter leaves in the example.

Gain in dB from 0 to 62.5 Hz for six low-pass filters at 10 Hz: Bessel falls slowest, Butterworth and Chebyshev I in between, Chebyshev II and elliptic fall fastest then level off near -40 dB, FIR falls steeply into a row of dips below -60 dB

Chart 2. Gain of the six designs, low-pass at 10 Hz

Step responses over 0.5 s: Bessel rises fastest with almost no overshoot; Butterworth, Chebyshev I and elliptic overshoot to about 1.1 and ring, the Chebyshev I and elliptic settling at 0.89; Chebyshev II rises more slowly; FIR stays near 0 until about 0.15 s, then rises

Chart 3. Step response of each design, one pass

methodgain at 2 Hzgain at 50 Hzovershootdelay at 2 Hzerror left
no filter10 dB—00.367
Butterworth1.0000−60.8 dB11.0%42 ms0.028
Chebyshev I0.9427−72.7 dB22.0%46 ms0.082
Chebyshev II0.9998−42.3 dB13.0%75 ms0.020
elliptic0.9319−44.5 dB24.1%38 ms0.096
Bessel0.9874−46.7 dB1.0%34 ms0.029
FIR1.0043−74.7 dB7.7%201 ms0.029

Table 2. The six designs on the example. Delay: one pass. Error left: RMS against the true 2 Hz wave after zero-phase filtering, ends excluded

Every design reduces the error from 0.367 to below 0.1. The two filters with passband ripple, Chebyshev I and elliptic, leave the most residual error: at 2 Hz, they reduce the wave amplitude by 6–7%, reflecting the passband ripple specified in Math 6. The other four agree within 0.01.

In summary:

The basic calculator runs Butterworth filters in your browser. The advanced calculator offers all six designs, computed on the server.

Key Ideas

A filter is fully described by its response. These six ideas determine whether that response does what you want.

Cutoff and Order: The −3 dB Point and the Roll-Off

Cutoff $f_c$ is where the gain has dropped to $1/\sqrt{2} = 0.7071$, or −3 dB—half the power. Order $n$ sets the roll-off: well past the cutoff, the gain falls by $20n$ dB for every tenfold increase in frequency (Chart 4).

Butterworth gain in dB against frequency for order 1, 2, 4 and 8, all passing through -3 dB at 10 Hz; the higher the order, the steeper the fall, order 8 leaving the chart below -100 dB before 40 Hz

Chart 4. Butterworth low-pass at 10 Hz, order 1, 2, 4 and 8

orderroll-offgain at 50 Hzstep overshootsections
1−20 dB/decade−15.3 dB0.0%1
2−40 dB/decade−30.4 dB4.4%1
4−80 dB/decade−60.8 dB11.0%2
8−160 dB/decade−121.6 dB16.5%4

Table 3. Order against attenuation and ringing

Doubling the order doubles the roll-off in decibels per decade. A higher order is not free: the edge gets sharper, but the filter generally produces more ringing and overshoot after sudden changes.

Phase Lag: Why Zero-Phase Filtering Needs the Whole Record

Causal filtering runs once, forward in time, using only past samples—the requirement for a real-time system. A causal filter generally delays the signal. The delay at a given frequency is the group delay $\tau(f)$; for the order-4 Butterworth filter at 2 Hz, it is 42.1 ms (Chart 5, red).

Zero-phase filtering runs the same filter forward and then backward over the result. The backward pass exactly cancels the phase shift introduced by the forward pass, while the gain is applied twice (Math 11).

$$G_{\text{zero-phase}}(f) = G(f)^2, \qquad \tau_{\text{zero-phase}}(f) = 0$$

Math 11.

The first second of the example: the true 2 Hz wave dashed, the zero-phase output in blue lying on it, and the causal output in red, the same shape shifted about 40 ms to the right

Chart 5. Causal and zero-phase Butterworth, order 4, 10 Hz, on the example

filteringdelay at 2 Hzerror against the waveerror against the wave, delayed
causal42.3 ms0.3690.028
zero-phase1.5 ms0.028—

Table 4. Measured delay and RMS error, ends excluded

The causal output is just as clean: its error drops to 0.028 once the 42 ms delay is taken into account. But it is late. When compared at the same instant, its error is 0.369—about as large as the error of the unfiltered data. Zero-phase filtering removes the delay: the measured residual delay of 1.5 ms is less than one sample (4 ms).

The cost is that the backward pass needs samples from the future, so zero-phase filtering works only on recorded data, never in real time. The gain is squared as well, so the original cutoff becomes the −6 dB point, and an order-4 filter has the same asymptotic roll-off as an order-8 filter.

The Moving Average Is a Low-Pass Filter, a Poor One

An $m$-point moving average is an FIR filter with $m$ equal weights. Its gain has a closed-form expression (Math 12).

$$G(f) = \left| \frac{\sin(\pi m f / f_s)}{m \sin(\pi f / f_s)} \right|$$

Math 12.

An 11-point average at $f_s = 250$ Hz falls to −3 dB at 10.10 Hz—nearly the cutoff of the example. Chart 6 compares it with an order-4 Butterworth filter having exactly the same −3 dB point.

Gain in dB up to 125 Hz: the moving average falls to a dip at 22.7 Hz, then rises again into humps near -13, -17, -20 dB between further dips; the Butterworth filter falls smoothly past -60 dB at 50 Hz

Chart 6. An 11-point moving average and a Butterworth filter with the same −3 dB point

filter−3 dB pointgain at 50 Hzhighest gain past 22.7 Hz
moving average, 11 points10.10 Hz−20.8 dB−13.0 dB
Butterworth, order 410.10 Hz−60.4 dB−29.0 dB

Table 5. The same −3 dB point, very different stopbands

The moving average's gain falls to zero at multiples of $f_s / m = 22.7$ Hz, then rises again between them into sidelobes. At their worst, the sidelobes let 22% of the input amplitude through (−13 dB). At 50 Hz, the moving average lets 9% of the hum through—95 times as much as the Butterworth filter. A moving average is excellent at what smoothing asks of it: it is simple and produces no overshoot. But as a filter, it has no useful stopband.

Ripple Against Sharpness

Passband ripple is the wobble in gain below the cutoff. Chart 7 zooms in on the passband of the five feedback designs.

Gain from 0 to 15 Hz between 0.6 and 1: Butterworth flat at 1 until about 7 Hz; Chebyshev I and elliptic oscillating between 0.89 and 1 up to 10 Hz, then dropping steeply; Chebyshev II flat at 1 until 3 Hz, then falling early; Bessel drooping gradually from the start

Chart 7. Passband gain of the five feedback designs, low-pass at 10 Hz

Chebyshev I and elliptic keep their gain between 0.8913 and 1 all the way to 10 Hz, then drop the fastest. Butterworth stays at 1 longer, then bends down to 0.7071 at 10 Hz. Bessel starts to droop immediately. No design can be both flat and steep: the ripple is what pays for the sharper edge.

Edges: The Start-Up Transient

A causal filter starts from rest, as if the signal had been zero before the first sample. Its output needs a few time constants to catch up: in Chart 5, the red curve starts at 0 and lags behind. For the FIR design, this start-up transient lasts a full 200 ms.

Zero-phase filtering with scipy.signal.sosfiltfilt—and in both calculators here—reduces edge effects by extending the record at both ends before filtering. It pads each end by $3(2s + 1)$ samples, where $s$ is the number of second-order sections, using an odd reflection of the data. Each pass starts in the steady state corresponding to the first or last value. For an order-4 filter, that is 15 samples, or 60 ms. In the first 0.1 s of the example, the zero-phase output has an RMS error of 0.048, compared with 0.028 in the interior.

The record must be longer than the padding. A record with fewer than 16 samples cannot be filtered with zero phase at order 4, so the calculators reject it and report the reason.

Nyquist: A Filter Cannot Undo Aliasing

A sampled signal can represent frequencies only up to the Nyquist frequency, $f_s / 2$. A cutoff above it is not meaningful for the sampled data, and both calculators reject one. Anything above $f_s / 2$ before sampling does not simply disappear: it folds down to a lower frequency, an effect called aliasing.

Chart 8 samples a 200 Hz tone at 250 Hz. The resulting samples are exactly the same as those of a 50 Hz tone with a 180° phase reversal.

Over 40 ms, a fast 200 Hz sine and a slow dashed 50 Hz sine; every one of the black sample dots, 4 ms apart, lies on both curves

Chart 8. A 200 Hz tone sampled at 250 Hz lands on 50 Hz

No digital filter can distinguish this alias from a real 50 Hz hum: in the sampled data, they are identical. The only way to prevent this is to use an analog low-pass filter before the analog-to-digital converter. The Fourier transform page shows where an alias appears in the spectrum.

Filter in hertz, check the response, and sample fast enough first.

REFs

SciPy scipy.signal.butter SciPy scipy.signal.sosfiltfilt SciPy scipy.signal.firwin Wikipedia, Butterworth filter Wikipedia, Chebyshev filter Wikipedia, Elliptic filter Wikipedia, Bessel filter Wikipedia, Finite impulse response Smoothing Methods: Moving Average, EWMA, Savitzky-Golay, Gaussian, Median Fourier Transform (DFT, FFT): What Frequencies Are in My Data? Detrending & Baseline Correction: How to Remove Drift from Measured Data