CHEBY1
The Chebyshev Type I filter is designed to have a steeper roll-off than the Butterworth filter. This is achieved at the expense of allowing ripple in the passband.
These filters have the property that they minimize the peak error over the passband by allowing an equiripple response.
|H(j\omega)|^2 = \frac{1}{1 + \epsilon^2 T_n^2(\frac{\omega}{\omega_c})}
where T_n is the n-th order Chebyshev polynomial.
Excel Usage
=CHEBY1(N, rp, Wn, btype, filter_output_form, analog, fs)
N(int, required): The order of the filter.rp(float, required): The maximum ripple allowed below unity gain in the passband (dB).Wn(list[list], required): Critical frequency or frequencies.btype(str, optional, default: “lowpass”): The type of filter.filter_output_form(str, optional, default: “ba”): Type of output representation.analog(bool, optional, default: false): When True, return an analog filter.fs(float, optional, default: null): The sampling frequency of the digital system.
Returns (list[list]): Filter coefficients or representation as a 2D array.
Example 1: Low-pass (b, a)
Inputs:
| N | rp | Wn | btype |
|---|---|---|---|
| 2 | 1 | 0.1 | lowpass |
Excel formula:
=CHEBY1(2, 1, 0.1, "lowpass")
Expected output:
| Result | ||
|---|---|---|
| 0.0205152 | 0.0410304 | 0.0205152 |
| 1 | -1.61852 | 0.710593 |
Example 2: Band-pass (SOS)
Inputs:
| N | rp | Wn | btype | filter_output_form | |
|---|---|---|---|---|---|
| 2 | 0.5 | 0.2 | 0.4 | bandpass | sos |
Excel formula:
=CHEBY1(2, 0.5, {0.2,0.4}, "bandpass", "sos")
Expected output:
| Result | |||||
|---|---|---|---|---|---|
| 0.0930926 | 0.186185 | 0.0930926 | 1 | -0.467443 | 0.589099 |
| 1 | -2 | 1 | 1 | -1.4082 | 0.72872 |
Python Code
Show Code
import numpy as np
from scipy.signal import cheby1 as scipy_cheby1
def cheby1(N, rp, Wn, btype='lowpass', filter_output_form='ba', analog=False, fs=None):
"""
Chebyshev Type I digital and analog filter design (passband ripple).
See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.cheby1.html
This example function is provided as-is without any representation of accuracy.
Args:
N (int): The order of the filter.
rp (float): The maximum ripple allowed below unity gain in the passband (dB).
Wn (list[list]): Critical frequency or frequencies.
btype (str, optional): The type of filter. Valid options: Lowpass, Highpass, Bandpass, Bandstop. Default is 'lowpass'.
filter_output_form (str, optional): Type of output representation. Valid options: Numerator/Denominator, Pole-Zero, Second-Order Sections. Default is 'ba'.
analog (bool, optional): When True, return an analog filter. Default is False.
fs (float, optional): The sampling frequency of the digital system. Default is None.
Returns:
list[list]: Filter coefficients or representation as a 2D array.
"""
try:
if isinstance(Wn, list):
wn_flat = [float(v) for row in Wn for v in row]
wn_val = wn_flat[0] if len(wn_flat) == 1 else wn_flat
else:
wn_val = float(Wn)
result = scipy_cheby1(
int(N),
float(rp),
wn_val,
btype=btype,
analog=bool(analog),
output=filter_output_form,
fs=float(fs) if fs is not None else None
)
if filter_output_form == 'ba':
b, a = result
max_len = max(len(b), len(a))
return [b.tolist() + [""] * (max_len - len(b)), a.tolist() + [""] * (max_len - len(a))]
elif filter_output_form == 'zpk':
z, p, k = result
max_len = max(len(z), len(p), 1)
return [z.tolist() + [""] * (max_len - len(z)), p.tolist() + [""] * (max_len - len(p)), [float(k)] + [""] * (max_len - 1)]
else: # sos
return result.tolist()
except Exception as e:
return f"Error: {str(e)}"Online Calculator
The order of the filter.
The maximum ripple allowed below unity gain in the passband (dB).
Critical frequency or frequencies.
The type of filter.
Type of output representation.
When True, return an analog filter.
The sampling frequency of the digital system.