LeastSquaresFilterKernel
✖
LeastSquaresFilterKernel
creates a k-band finite impulse response (FIR) filter kernel of length n designed using a least squares method, given the specified frequencies ωi and amplitudes ai.
Details and Options
- LeastSquaresFilterKernel returns a numeric list of length n of the impulse response coefficients of an FIR filter that has the minimum mean-squared error.
- The impulse response of the filter is computed using the inverse discrete-time Fourier transform.
- In LeastSquaresFilterKernel[{"type",spec},n], filter specification can be any of the following:
-
{"Lowpass",ωc} lowpass filter with cutoff frequency ωc {"Highpass",ωc} highpass filter with cutoff frequency ωc {"Bandpass",{ωc1,ωc2}} bandpass filter with passband from ωc1 to ωc2 {"Bandpass",{{ω,q}}} bandpass filter with center frequency ω and quality factor q {"Bandstop",{ωc1,ωc2}} bandstop filter with stopband from ωc1 to ωc2 {"Bandstop",{{ω,q}}} bandstop filter with center frequency ω and quality factor q {"Multiband",{ω1,…,ωk-1},{a1,…,ak}} multiband filter specification with k bands {"Differentiator",ωc} differentiator filter with cutoff frequency ωc {"Hilbert",ωc} Hilbert filter with cutoff frequency ωc - If "type" is omitted, "Multiband" is assumed.
- Frequencies should be given in an ascending order such that 0≤ω1<ω2<…<ωk-1≤π.
- Amplitude value a1 corresponds to the frequency band 0 to ω1, and amplitude ak corresponds to the frequency band ωk-1 to π.
- Amplitude values should be non-negative. Typically, values ai=0 specify a stopband, and values ai=1 specify a passband.
- The quality factor q is defined as , with being the center frequency of a bandpass or bandstop filter. Higher values of q give narrower filters.
- The kernel ker, returned by LeastSquaresFilterKernel, can be used in ListConvolve[ker,data] to apply the filter to data.
- LeastSquaresFilterKernel takes a WorkingPrecision option, which specifies the precision to use in internal computations. The default setting is WorkingPrecision->MachinePrecision.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
https://wolfram.com/xid/01lwnw3jvi5p9n03m-chrus7
Magnitude plot of the filter and its ideal lowpass prototype:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-tiwgg
https://wolfram.com/xid/01lwnw3jvi5p9n03m-v8glsc
https://wolfram.com/xid/01lwnw3jvi5p9n03m-62evgh
Magnitude plot of the filter and its "brickwall" specification:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-t5yvtd
Scope (6)Survey of the scope of standard use cases
https://wolfram.com/xid/01lwnw3jvi5p9n03m-dcwoxr
https://wolfram.com/xid/01lwnw3jvi5p9n03m-p2fmiv
https://wolfram.com/xid/01lwnw3jvi5p9n03m-fxrrwc
https://wolfram.com/xid/01lwnw3jvi5p9n03m-4ph5hw
Same filter using center frequency and quality factor specification:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-fch527
https://wolfram.com/xid/01lwnw3jvi5p9n03m-he44b3
https://wolfram.com/xid/01lwnw3jvi5p9n03m-6vnbt3
Same filter using center frequency and quality factor specification:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-ddais3
https://wolfram.com/xid/01lwnw3jvi5p9n03m-9oylzg
https://wolfram.com/xid/01lwnw3jvi5p9n03m-mtmi9r
A full-band Hilbert FIR kernel:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-6unn7v
https://wolfram.com/xid/01lwnw3jvi5p9n03m-txphmk
Plot of the imaginary part of the filter:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-efkuld
A half-band lowpass FIR kernel:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-c0w4oz
Magnitude plot of the filter and the half-band frequency :
https://wolfram.com/xid/01lwnw3jvi5p9n03m-bj82uu
Convert the half-band lowpass filter to highpass:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-wqvz2n
Magnitude plots of the two half-band filters:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-ucklnk
Generalizations & Extensions (1)Generalized and extended use cases
Applications (4)Sample problems that can be solved with this function
Create a lowpass FIR filter with cutoff frequency of and length n=15:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-ggbv4q
Taper the filter using a Blackman window to improve stopband attenuation:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-zznff
https://wolfram.com/xid/01lwnw3jvi5p9n03m-cy9uzi
Log-magnitude plot of the power spectra of the two filters:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-j105sx
Triple the length of the filter to match the bandwidth of the non-windowed sequence:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-vkdvr
Lowpass filtering of a dual-tone multi-frequency (DTMF) signal:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-gffkg6
This shows the spectrum of the dual-tone signal:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-z5lwj
Create a windowed lowpass filter kernel with a cutoff frequency of 953 Hz for a sound sampled at 8000 Hz:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-8il5wx
https://wolfram.com/xid/01lwnw3jvi5p9n03m-b2ac4
Here is the spectrum of the filtered signal:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-iltw9d
Create a list of Nyquist filters:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-rq131u
https://wolfram.com/xid/01lwnw3jvi5p9n03m-l406iz
Take a derivative of the rows of an image:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-yqzym
https://wolfram.com/xid/01lwnw3jvi5p9n03m-dpq7pn
Properties & Relations (3)Properties of the function, and connections to other functions
Specifying the list of frequencies and amplitudes creates a multiband filter kernel:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-53xsuo
Increasing quality factors leads to narrower filters:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-bf4376
In a half-band filter of length , coefficients at positions for positive integer values of are zero:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-5w408o
https://wolfram.com/xid/01lwnw3jvi5p9n03m-5cwuhx
In a -band filter, coefficients at positions are zero:
https://wolfram.com/xid/01lwnw3jvi5p9n03m-q7dnfl
https://wolfram.com/xid/01lwnw3jvi5p9n03m-ga1g28
Wolfram Research (2012), LeastSquaresFilterKernel, Wolfram Language function, https://reference.wolfram.com/language/ref/LeastSquaresFilterKernel.html (updated 2015).
Text
Wolfram Research (2012), LeastSquaresFilterKernel, Wolfram Language function, https://reference.wolfram.com/language/ref/LeastSquaresFilterKernel.html (updated 2015).
Wolfram Research (2012), LeastSquaresFilterKernel, Wolfram Language function, https://reference.wolfram.com/language/ref/LeastSquaresFilterKernel.html (updated 2015).
CMS
Wolfram Language. 2012. "LeastSquaresFilterKernel." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/LeastSquaresFilterKernel.html.
Wolfram Language. 2012. "LeastSquaresFilterKernel." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/LeastSquaresFilterKernel.html.
APA
Wolfram Language. (2012). LeastSquaresFilterKernel. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LeastSquaresFilterKernel.html
Wolfram Language. (2012). LeastSquaresFilterKernel. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LeastSquaresFilterKernel.html
BibTeX
@misc{reference.wolfram_2024_leastsquaresfilterkernel, author="Wolfram Research", title="{LeastSquaresFilterKernel}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/LeastSquaresFilterKernel.html}", note=[Accessed: 10-January-2025
]}
BibLaTeX
@online{reference.wolfram_2024_leastsquaresfilterkernel, organization={Wolfram Research}, title={LeastSquaresFilterKernel}, year={2015}, url={https://reference.wolfram.com/language/ref/LeastSquaresFilterKernel.html}, note=[Accessed: 10-January-2025
]}