# A filter removing forbidden information in the stop-band

Is it possible, and how could it be done, to make an extension of filters that converts the signal in the filter's stop-band into noise with no information content or at least with zero correlation to the input signal in that frequency range, with only an arbitrarily small degradation of the signal in the pass-band?

To visualize this, here's a low-pass filter magnitude frequency response with equiripple stopband lobes peaking at -72.5 dB:

When a sum of two sinusoidally modulated frequency sweeps (a good test signal for trying to solve the problem) is filtered, a resulting spectrogram is:

The best approach I can currently think of is to add to the input signal some noise. Naively adding triangular noise at 2.5 dB higher power than a sinusoid at the peak of a stop-band lobe still shows the sinusoids in the spectrogram:

Cranking up the noise to peak sinusoid power at stopband + 18.5 dB almost fully hides the sinusoids over the stopband:

But it's a lot of noise. I didn't filter the noise to only the stop-band, because it's extra computational effort, and because in some applications the signal would be decimated and the noise would end up in the pass band anyhow.

I have also been thinking about randomly switching the output between those of a filterbank. The switching would move the stop-band zeros around while causing minimal frequency response fluctuation in the pass-band. But this approach seems to be a dead end. If the input is a complex sinusoid within the stop band, then in order to kill the correlation between the input and the scrambler's output, the sum of the frequency responses of the filterbank filters would need to be zero at that frequency. If that was simultaneously possible, as we require, for all stop-band frequencies, it would also be possible to take a sum of the impulse responses of the filterbank filters to obtain a filter with a uniformly zero stop band frequency response. It's well known that that is not possible.

Maybe no ideal method exists.

Python code for the plots:

import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
c0 = signal.remez(8, [0, 0.25], [1], maxiter=100)
c = np.zeros(c0.size*2-1)
c[0::2] = c0
c[c0.size-1] = 1
c = c*0.5
freq, response = signal.freqz(c)
plt.plot(range(-c0.size+1, c0.size, 1), c, 'x')
plt.grid(True)
plt.show()
plt.plot(freq/(2*np.pi), 20*np.log10(np.abs(response)))
plt.grid(True)
plt.show()
print("Stop band ripple (dB):")
print(20*np.log10(np.abs(response[-1])))
delay_c = np.concatenate([np.zeros((c.size // 2)), [1], np.zeros((c.size // 2))])
freq, response = signal.freqz(delay_c - c)
plt.plot(range(-c0.size+1, c0.size, 1), delay_c - c, 'x')
plt.grid(True)
plt.show()
plt.plot(freq/(2*np.pi), 20*np.log10(np.abs(response)))
plt.grid(True)
plt.show()

N = 65536
f = 2
x = np.sin((lambda x: 0.5*np.pi*x - 0.5*np.sin(np.pi*x/N*f)*N/f)(np.arange(N)))
f = 5
x += np.sin((lambda x: 0.5*np.pi*x - 0.5*np.sin(np.pi*x/N*f)*N/f)(np.arange(N)))

def get_spectrogram(x):
return signal.spectrogram(x, window=('gaussian', 64), scaling='spectrum', nperseg=1024, noverlap=1024-64, nfft=1024, detrend=False)

def plot_spectrogram(x):
f, t, Sxx = get_spectrogram(x)
plt.figure(figsize=(10,5))
plt.pcolormesh(t, f, 10*np.log10(Sxx/np.max(Sxx) + 10e-100), shading='gouraud', cmap='pink', vmin=-112, vmax=0)
plt.show()

f, t, Sxx = get_spectrogram(x);
plot_spectrogram(x)

y = np.convolve(x, c)
plot_spectrogram(y);

epsilon = 10**(-70/20)*np.sqrt(3) #sqrt(3) = sqrt(1/2)/sqrt(1/6) = sine rms / triangular noise rms
r = (np.random.uniform(size=y.size)-np.random.uniform(size=y.size))*epsilon
z = y + r
plot_spectrogram(z);

epsilon = 10**(-54/20)*np.sqrt(3)
z = y + (np.random.uniform(size=y.size)-np.random.uniform(size=y.size))*epsilon
plot_spectrogram(z);

• is this for audio or other kind of signals?, how much dB is your stopband?, the filter is elliptic or all-pole? is the domain digital or analog? how much SNR you want? Commented Feb 14, 2022 at 2:00
• perhaps you can make your filter very high order, like 8th order or more, if the attenuation is so brutal the stopband will be masked away by the noisefloor of the system being analog or digital, digital systems also have a noise floor depending on how much bits is the sampling resolution Commented Feb 14, 2022 at 2:08
• @LeandroAlsina I don't have those numbers. I've been thinking of digital applications only. In artificial neural networks, this could be used to prevent deterministic spectral imaging/aliasing artifacts. There might be applications in (secure) communications and such. Commented Feb 14, 2022 at 6:35
• I see the response of your lowpass filter, is it a FIR?, there is a comb-filter effect response at the stop band, which makes me suspect is a FIR, delay based filter. why dont you use an IIR?, with an IIR you can achieve much better attenuation at the stop band, and these dont require too much computational power Commented Feb 19, 2022 at 2:57
• It's a linear-phase finite impulse response (FIR) filter. My main interest is the machine learning context where infinite impulse response (IIR) filters are problematic. The filter type doesn't matter for the question's visualization purposes. If there is an IIR filter based solution to the question, it will be equally appreciated. Commented Feb 19, 2022 at 6:32

Well, the naive approach would of course be using the complementary of your band-pass filter (letting through the allowed information) as band-stop filter, and use that to shape uncorrelated noise to be where the stop-band of the original filter is. Then, add both.

If you don't want to do that, for example because you've read about dirty paper coding and realize the "attacker" can infer information about the stop-band noise from the transition width to recover part of the "whitened out" regions (this is a bit of speculation – I don't know your filter, your allowed signal / information etc), things get a bit more complicated.

One excellent information eraser is multiplication with a random variable; assuming your signal amplitude at every frequency was continuously distributed, the target distribution after multiplication would be normal, as that's the highest-entropy-per-variance-i.e.-power distribution.

So, problem: how do we multiply all frequencies outside passband with a (individually) white, uncorrelated noise, but not the passband? Well, we start by looking at things as point-wise multiplication in (discrete) frequency domain. Well, that does work (all practical issues of "how to get into frequency domain" aside – that's what OFDM or GFDM would solve, but it puts restrictions on the structure of your signals). So, the trick would be

1. Generate white noise
2. filter it (time domain) or mask it (frequency domain) to affect the out-of-allowed-band region only
3. multiply it point-wise in frequency domain with the signal
4. (if necessary) transform back to time domain

Interestingly, steps 2/3 suggest that you could, instead of doing the multiplication in frequency domain, convolve your signal with bandlimited white noise and preserve your signal of interest – which feels wrong. I need to think about this.

• The problem with the naive approach of noise addition is that some correlation with the forbidden signal will still remain. Commented Aug 31, 2021 at 12:07
• exactly; you can achieve zero correlation by multiplication with a zero-mean random signal Commented Aug 31, 2021 at 12:08