3

I am a student working with time-series data which we feed into a neural network for classification (my task is to build and train this NN).

We're told to use a band-pass filter of 10 Hz to 150 Hz since anything outside that is not interesting.

After applying the band-pass, I've also down-sampled the data to 300 samples per second (originally it was 768 Hz). My understanding of the Shannon Nyquist sampling theorem is that, after applying the band-pass, any information in the data will be perfectly preserved at this sample-rate.

However, I got into a discussion with my supervisor who claimed that 300 Hz might not be sufficient even if the signal was band-limited. She says that it is only the minimum sample rate, not necessarily the best sample rate.

My understanding of the sampling theorem makes me think the supervisor is obviously wrong, but I don't want to argue with my supervisor, especially in case I'm actually the one who has misunderstood.

Can anyone help to confirm my understanding or provide some clarification? And how should I take this up with my supervisor (if at all).

AnneH
  • 31
  • 1

2 Answers2

0

The Nyquist-Shannon theorem states that the sampling frequency should at-least be twice of bandwidth, i.e.,

fs > 2B

So, this is the minimal criteria. If the sampling frequency is less than 2B then there will be aliasing. There is no upper limit on sampling frequency, but more the sampling frequency, the better will be the reconstruction.

So, I think your supervisor is right in saying that it is the minimal condition and not the best one.

fam
  • 583
  • 3
  • 14
  • Thank you very much for the input. Could you also clarify, how it would be better? I tried to run some tests and the RMS error of reconstructing data does not improve above 2B. – AnneH Aug 23 '21 at 09:36
  • Considering time domain, when you increase the sampling frequency, less information is lost and it is easier to estimate the missing values, when you reconstruct the sample. Think this way; what is easier for you visually; to interpolate the samples which are lying very far away or the samples which are very close to each other. Similarly, you can think what is happening in the frequency domain when you increase or decrease the sampling frequency. Hope that clarifies your concern. – fam Aug 23 '21 at 10:20
  • Thanks for your patience. I'm not sure I understand. As a test I've generated noisy data of 768 samples per second, then applied band-pass to 10 - 150 Hz. With the band limited data I then down-sampled and up-sampled again and calculate the RMS-error of the result and the sequence before down-sampling. If i down-sample to below 300 Hz then there is an increasing error the lower the sample-rate. But above that it is very small (~floating point presicion) and relatively constant: I can see no improvement with increasing it. – AnneH Aug 23 '21 at 11:00
  • It is not necessary that the precision will increase with an increase in the sampling frequency. There are some other factors that should be taken into account. But going below `2B` will not be good. Although, just for mentioning, there are some cases where even the signal is appropriately reconstructed when the sampling frequency is below `2B`. Hence the statement of your supervisor "it is only the minimum sample rate, not necessarily the best sample rate." – fam Aug 24 '21 at 04:01
0

Actually, you and your supervisor are both wrong. The minimum sampling rate required to faithfully represent a real-valued time series whose spectrum lies between 10 Hz and 150 Hz is 140 Hz, not 300 Hz. I'll explain this, and then I'll explain some of the context that shows why you might want to "oversample", as it is referred to (spoiler alert: Bailian-Low Theorem). The supervisor is mixing folklore into the discussion, and when folklore is not properly-contexted, it tends to telephone tag into fakelore. (That's a common failing even in the peer-reviewed literature, by the way). And there's a lot of fakelore, here, that needs to be defogged.

For the following, I will use the following conventions.

There's no math layout on Stack Overflow (except what we already have with UTF-8), so ...

a^b denotes a raised to the power b.

∫_I (⋯x⋯) dx denotes an integral of (⋯x⋯) taken over all x ∈ I, with the default I = ℝ.

The support supp φ (or supp_x φ(x) to make the "x" explicit) of a function φ(x) is the smallest closed set containing all the x-es for which φ(x) ≠ 0. For regularly-behaving (e.g. continuously differentiable) functions that means a union of closed intervals and/or half-rays or the whole real line, itself. This figures centrally in the Shannon-Nyquist sampling theorem, as its main condition is that a spectrum have bounded support; i.e. a "finite bandwidth".

For the Fourier transform I will use the version that has the 2π up in the exponent, and for added convenience, I will use the convention 1^x = e^{2πix} = cos(2πx) + i sin(2πx) (which I refer to as the Ramanujan Convention, as it is the convention I frequently used in my previous life oops I mean which Ramanujan secretly used in his life to make the math a whole lot simpler).

The set ℤ = {⋯, -2, -1, 0, +1, +2, ⋯ } is the integers, and 1^{x+z} = 1^x for all z∈ℤ - making 1^x the archetype of a periodic function whose period is 1.

Thus, the Fourier transform f̂(ν) of a function f(t) and its inverse are given by:

    f̂(ν) = ∫ f(t) 1^{-νt} dt, f(t) = ∫ f̂(ν) 1^{+νt} dν.

The spectrum of the time series given by the function f(t) is the function f̂(ν) of the cyclic frequency ν, which is what is measured in Hertz (Hz.); t, itself, being measured in seconds. A common convention is to use the angular frequency ω = 2πν, instead, but that muddies the picture.

The most important example, with respect to the issue at hand, is the Fourier transform χ̂_Ω of the interval function given by χ_Ω(t) = 1 if t ∈ [-½Ω,+½Ω] and χ_Ω(t) = 0 else:

    χ̂_Ω(t)  = ∫_[-½Ω,+½Ω] 1^ν dν
            = {1^{+½Ω} - 1^{-½Ω}}/{2πi}
            = {2i sin πΩ}/{2πi}
            = Ω sinc πΩ

which is where the function sinc x = (sin πx)/(πx) comes into play.

The cardinal form of the sampling theorem is that a function f(t) can be sampled over an equally-spaced sampled domain T ≡ { kΔt: k ∈ ℤ }, if its spectrum is bounded by supp f̂ ⊆ [-½Ω,+½Ω] ⊆ [-1/(2Δt),+1/(2Δt)], with the sampling given as

    f(t) = ∑_{t'∈T} f(t') Ω sinc(Ω(t - t')) Δt.

So, this generally applies to [over-]sampling with redundancy factors 1/(ΩΔt) ≥ 1. In the special case where the sampling is tight with ΩΔt = 1, then it reduces to the form

    f(t) = ∑_{t'∈T} f(t') sinc({t - t'}/Δt).

In our case, supp f̂ = [10 Hz., 150 Hz.] so the tightest fits are with 1/Δt = Ω = 300 Hz.

This generalizes to equally-spaced sampled domains of the form T ≡ { t₀ + kΔt: k ∈ ℤ } without any modification.

But it also generalizes to frequency intervals supp f̂ = [ν₋,ν₊] of width Ω = ν₊ - ν₋ and center ν₀ = ½ (ν₋ + ν₊) to the following form:

    f(t) = ∑_{t'∈T} f(t') 1^{ν₀(t - t')} Ω sinc(Ω(t - t')) Δt.

In your case, you have ν₋ = 10 Hz., ν₊ = 150 Hz., Ω = 140 Hz., ν₀ = 80 Hz. with the condition Δt ≤ 1/140 second, a sampling rate of at least 140 Hz. with

    f(t) = (140 Δt) ∑_{t'∈T} f(t') 1^{80(t - t')} sinc(140(t - t')). 

where t and Δt are in seconds.

There is a larger context to all of this. One of the main places where this can be used is for transforms devised from an overlapping set of windowed filters in the frequency domain - a typical case in point being transforms for the time-scale plane, like the S-transform or the continuous wavelet transform.

Since you want the filters to be smoothly-windowed functions, without sharp corners, then in order for them to provide a complete set that adds up to a finite non-zero value over all of the frequency spectrum (so that they can all be normalized, in tandem, by dividing out by this sum), then their respective supports have to overlap.

(Edit: Generalized this example to cover both equally-spaced and logarithmic-spaced intervals.)

One example of such a set would be filters that have end-point frequencies taken from the set

    Π = { p₀ (α + 1)ⁿ + β {(α + 1)ⁿ - 1} / α: n ∈ {0,1,2,⋯} }

So, for interval n (counting from n = 0), you would have ν₋ = p_n and ν₊ = p_{n+1}, where the members of Π are enumerated

    p_n = p₀ (α + 1)ⁿ + β {(α + 1)ⁿ - 1} / α,
    Δp_n = p_{n+1} - p_n = α p_n + β = (α p₀ + β)(α + 1)ⁿ,
    n ∈ {0,1,2,⋯}

The center frequency of interval n would then be ν₀ = p_n + ½ Δp₀ (α + 1)ⁿ and the width would be Ω = Δp₀ (α + 1)ⁿ, but the actual support for the filter would overlap into a good part of the neighboring intervals, so that when you add up the filters that cover a given frequency ν the sum doesn't drop down to 0 as ν approaches any of the boundary points. (In the limiting case α → 0, this produces an equally-spaced frequency domain, suitable for an equalizer, while in the case β → 0, it produces a logarithmic scale with base α + 1, where octaves are equally-spaced.)

The other main place where you may apply this is to time-frequency analysis and spectrograms. Here, the role of a function f and its Fourier transform f̂ are reversed and the role of the frequency bandwidth Ω is now played by the (reciprocal) time bandwidth 1/Ω. You want to break up a time series, given by a function f(t) into overlapping segments f̃(q,λ) = g(λ)* f(q + λ), with smooth windowing given by the functions g(λ) with bounded support supp g ⊆ [-½ 1/Ω, +½ 1/Ω], and with interval spacing Δq much larger than the time sampling Δt (the ratio Δq/Δt is called the "hop" factor). The analogous role of Δt is played, here, by the frequency interval in the spectrogram Δp = Ω, which is now constant.

Edit: (Fixed the numbers for the Audacity example)

The minimum sampling rate for both supp_λ g and supp_λ f(q,λ) is Δq = 1/Ω = 1/Δp, and the corresponding redundancy factor is 1/(ΔpΔq). Audacity, for instance, uses a redundancy factor of 2 for its spectrograms. A typical value for Δp might be 44100/2048 Hz., while the time-sampling rate is Δt = 1/(2×3×5×7)² second (corresponding to 1/Δt = 44100 Hz.). With a redundancy factor of 2, Δq would be 1024/44100 second and the hop factor would be Δq/Δt = 1024.

If you try to fit the sampling windows, in either case, to the actual support of the band-limited (or time-limited) function, then the windows won't overlap and the only way to keep their sum from dropping to 0 on the boundary points would be for the windowing functions to have sharp corners on the boundaries, which would wreak havoc on their corresponding Fourier transforms.

The Balian-Low Theorem makes the actual statement on the matter.

https://encyclopediaofmath.org/wiki/Balian-Low_theorem

And a shout-out to someone I've been talking with, recently, about DSP-related matters and his monograph, which provides an excellent introductory reference to a lot of the issues discussed here.

    A Friendly Guide To Wavelets
    Gerald Kaiser
    Birkhauser 1994

He said it's part of a trilogy, another installment of which is forthcoming.

NinjaDarth
  • 287
  • 1
  • 3