1
$\begingroup$

I have the following code:

sigma_th = 0.08;
ph_noise = sigma_th*randn(1,2^22);
[b,a] = butter(1,4e6/1e9,'high');
ph_noise_out = filter(b, a, ph_noise);
figure(1);
[psd1,w] = pwelch(ph_noise,blackmanharris(2^22/8),[],[],100e9,'onesided');
semilogx(w,10*log10(psd1/2));grid on;
hold on;
[psd2,w] = pwelch(ph_noise_out,blackmanharris(2^22/8),[],[],100e9,'onesided');
semilogx(w,10*log10(psd2/2));grid on;
[psd3,w] = pwelch(ph_noise_out - ph_noise,blackmanharris(2^22/8),[],[],100e9,'onesided');
semilogx(w,10*log10(psd3/2));grid on;

Here, I generate a noise signal ph_noise and high pass filter the noise using a butterworth filter to get the output ph_noise_out.
If I check the power spectral density of the ph_noise and ph_noise_out, I see that the output spectrum is filtered at low frequencies but is exactly the same at high frequencies. But when I plot the difference between the two noises, I see that the difference falls down as 20dB/dec. Why is the difference falling so slowly? How can I make it fall faster?
PS. The blue curve is the ph_noise, orange is the filtered noise ph_noise_out and yellow is the power of the difference signal. enter image description here

$\endgroup$
  • $\begingroup$ you should use a faster roll-off ( en.wikipedia.org/wiki/Roll-off ) $\endgroup$ – dsp_user Apr 3 at 10:24
  • $\begingroup$ But how can I set the roll-off for the difference? $\endgroup$ – sarthak Apr 3 at 10:30
  • $\begingroup$ In Matlab, the first argument of butter() is the filter order - increase it? $\endgroup$ – teeeeee Apr 3 at 10:34
  • $\begingroup$ It would increase the roll off for the filtered noise but not for the difference signal. The difference still falls at 20dB/dec. I just checked $\endgroup$ – sarthak Apr 3 at 10:35
  • $\begingroup$ If I see correctly, you are calculating a difference in time domain, this is somewhat tricky. Try calculating the spectra seperatly and calculate the difference from those. $\endgroup$ – Max Apr 3 at 11:03
3
$\begingroup$

The reason is the decorrelation due to the varying phase shift between the input and output. See the plot below showing the phase of the OP's high pass filter, and how closely it follows the cancellation when plotted on a log log scale (the higher frequency components of the two signals are better aligned in time and therefore have higher correlation leading to better cancellation).

The correlation between signals vs phase is proportional to the sine of the phase (signals in quadrature are uncorrelated consistent $\sin(\pi/2)=0$. For small angles the sine of the angle is the angle in radians hence we see the close match between the response of the phase and the cancellation of your signal as in your plots.

Angle of Filter vs Frequency

Due to the small angle, the OP's cancellation signal, assuming perfect amplitude matching, will have a magnitude that is directly proportional to the phase itself in radians between the two signals. Consider the cancellation of two signals with identical magnitude but a difference in phase:

$$y_1= Ae^{j\phi_1}$$ $$y_2= Ae^{j\phi_2}$$

$$y_1-y_2 = Ae^{j\phi_1}- Ae^{j\phi_2} = Ae^{j\phi_1}(1-Ae^{j(\phi_2-\phi_1)})$$ $$= Ae^{j\phi_1}e^{j(\phi_2-\phi_1)/2}(e^{-j(\phi_2-\phi_1)/2}-e^{j(\phi_2-\phi_1)/2})$$ $$ = -Ae^{j\phi_1}e^{j(\phi_2-\phi_1)/2}2j\sin\big((\phi_2-\phi_1)/2\big)$$ $$ = -2Aje^{j(\phi_1+\phi_2)/2}\sin\big((\phi_2-\phi_1)/2\big)$$ $$ = 2Ae^{j(\phi_1+\phi_2-\pi)/2}\sin\big((\phi_2-\phi_1)/2\big)$$

For a small difference angle $\phi_2-\phi_1$, $\sin\big((\phi_2-\phi_1)/2\big) \approx (\phi_2-\phi_1)/2$, so the above cancellation becomes:

$$\approx A(\phi_2-\phi_1)e^{j(\phi_1+\phi_2-\pi)/2}$$

And thus for small angles the magnitude of the cancellation is directly proportional to the difference in phase. And the cancellation ratio as the magnitude of the cancelled signal compared to the magnitude of the input signal would be the difference in phase directly:

$$|y_1-y_2|/|y_1| =| \phi_2-\phi_1|$$

To achieve what the OP is trying to do, the phase response of the filter must be compensated for before doing the subtraction. This would be much easier if a linear phase filter was used instead of the Butterworth filter as the phase compensation of the input signal could then be accomplished with a simple single tap delay. Of course, to completely cancel the signal the amplitudes would need to be exactly matched in the region of cancellation as well.

In practical application even with close matching a finite delay will exist between the two identical signals prior to subtraction, resulting in a high pass response with a cutoff of $1/T$ given a finite delay $T$. With a fixed delay $T$ the lower frequency components much less than $1/T$ in frequency would have a higher cancellation, and the decorrelation will go proportional to $f$ as the frequency approaches $1/T$. Signals much higher than $1/T$ would be decorrelated so would result in a $3$ dB increase as expected for the the sum of two uncorrelated signals.

| improve this answer | |
$\endgroup$
  • $\begingroup$ @sarthak you also clearly see here the phase dispersion I was referring to with your other question regarding a carrier tracking loop $\endgroup$ – Dan Boschen Apr 3 at 22:30
1
$\begingroup$

I see that the difference falls down as 20dB/dec.

Because you high pass also only has a 20 dB/octave slope. For first order filters the upwards slope of the high pass is symmetrical to the downwards slope of (1 - highpass) other than bilinear distortion. Your difference cannot fall faster than the high pass rises.

How can I make it fall faster?

You need to increase the filter order. However, in this case you run into time/phase alignment problem that Dan Boschen describes. You either need to use a linear phase FIR filter, using certain types of Butterworth filters with an alignment all passe filter in the "though" pass

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ This really has nothing to do with the roll-off of the filter (other than it's impact on group delay) since the cancellation is occurring in the region where the loss of the filter is minimal. $\endgroup$ – Dan Boschen Apr 3 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.