# How to make sense of LowpassFilter, SampleRate and the cutoff frequency ωc in different Mathematica versions?

How do you make sense of the scale of "time" and "sampling" when using LowpassFilter and SampleRate ?

Given the test data with components at 1Hz and 5Hz

data1 = Array[N[Sin[2 Pi #] + Sin[2 Pi 5 #]] &, 100, {-1, 1}];


I expect to apply a low-pass filter at 2Hz and 10Hz

data2 = N @ LowpassFilter[data1, 2, SampleRate -> 50];

data3 = N @ LowpassFilter[data1, 10, SampleRate -> 50];


And see that data3 contains a significant part of the 5Hz component.

What am I doing wrong here?

In Win7 64 and Mathematica 10.2 and 10.1 I get

ListPlot[
{
data1
, data2
, data3
}
, Joined -> True
, PlotRange -> {-2, 2}
, PlotStyle -> {Gray, Red, Blue}
]


while versions 9.0 and 10.0 behave differently.

Should I understand that these new versions have a bug?

• Results from v9 : !Mathematica graphics Jul 30 '15 at 16:01
• I get belisarius' result on 10.0.1, OSX. Jul 30 '15 at 16:02
• @belisarius, get your result in 9.0, 10.0, and mine in 10.1 and 10.2. Jul 30 '15 at 16:29
• @rhermans Should we add a Version10 tag then? Jul 30 '15 at 16:39
• I get the same result as @rhermans in 10.2, but these results all seem correct to me. The issue (to me, it would seem) is that $\omega_c$ is an angular frequency, so $f_c=\omega_c/(2\pi)$. I think the difference people are getting between 10.0 and 10.1/10.2 arises from different filtering techniques. Try: data2 = N@LowpassFilter[data1, Quantity[2, "Hertz"], SampleRate -> 50]; data3 = N@ LowpassFilter[data1, Quantity[10, "Hertz"], SampleRate -> 50]; and that looks to give the correct result. Jul 30 '15 at 16:42

It looks like your problem comes from the fact that $\omega_c$ will be referring to an angular frequency, so $$\omega_c=2\pi f_c$$ Therefore, you can get the desired result by changing your data2 and data3 definitions:

data2 = N@LowpassFilter[data1, 2*Pi*2, SampleRate -> 50];
data3 = N@LowpassFilter[data1, 2*Pi*10, SampleRate -> 50];


Alternatively, you can define it in terms of Hz:

data2 = N@LowpassFilter[data1, Quantity[2, "Hertz"], SampleRate -> 50];
data3 = N@LowpassFilter[data1, Quantity[10, "Hertz"], SampleRate -> 50];


And you get

Finally, the difference people seem to be getting in pre-10.1 and 10.1/10.2 seems to be different filter types. Specifying LowpassFilter will use whatever lowpass filter Wolfram has programmed in. It wouldn't surprise me to see them change the filter type, if it made sense to them, especially since there are other functions like ButterworthFilterModel that can be used for specifying the filter type explicitly.