3
$\begingroup$

I come from Fluid Mechanics domain so pardon me for asking a naive and fundamental question.

I am trying to perform high pass filtering on a set of positive real numbers (~Energy) using FFT. However, the result I obtain has a lot of negative values. I tried to quantify how many of them are negative and it seems $\sim50\%$ of these values are negative.

I tried looking up for an answer and I saw a general approach used in Image processing domain, where people offset these negative values or use some threshold. But in my case, I can't use either of these techniques because I need to look at some statistical quantities after the filtering process.

So I want to ask why do these negative numbers appear for a purely positive input and if so, are there any solutions for it?

$\endgroup$
2
  • 1
    $\begingroup$ As some posters request, please show us a plot of your original data and the high-pass filtered data. Upload an image somewhere, and we can inline it for you if you don't have the rep. $\endgroup$ – Peter K. Aug 28 '13 at 13:29
  • $\begingroup$ That's what high pass filters do. Is there some reason you believe it shouldn't have negative values? $\endgroup$ – endolith Aug 28 '13 at 19:28
6
$\begingroup$

A high pass filter has some properties that are similar to taking a derivative. The derivative of a function that is always positive will be negative wherever the slope is negative. There's nothing you can do about it. For example, take the function $f(t) = 400 + \sin \omega t$. This wiggles around between 399 and 401 (very positive), yet the derivative is $\omega \cos \omega t$. So the derivative (i.e., high-pass filter), will wiggle between $-\omega$ and $\omega$.

$\endgroup$
4
  • $\begingroup$ Just what I was going to say. The analogy between highpass filtering and differentiation is a good intuitive explanation for what the OP is seeing. $\endgroup$ – Jason R Aug 28 '13 at 12:46
  • $\begingroup$ Ok, that example really helped me understand how HPF behaves. However, the magnitude of negative values is relatively large and so it contaminates the results when I try to use a band-pass filter. So does this mean that the dataset I am looking at has very large $\omega$ causing this? $\endgroup$ – Sidhha Aug 28 '13 at 12:49
  • 1
    $\begingroup$ Look at the data in the time domain (or add a plot to your question). Do you see any parts where the signal's derivative would be large and negative (i.e. regions where it decreases rapidly)? That's one way to look at it. One question I would ask is why you expect the result to be nonnegative. What is the end application for the filtered data? $\endgroup$ – Jason R Aug 28 '13 at 13:05
  • 1
    $\begingroup$ Large values means that you have very abrupt changes in your data. It more likely means you have noise than that you have any real high frequency signal. High-pass filtering (and derivatives) tend to emphasize noise rather than signal. Typically the reason that you would high pass filter would be because you are looking for sharp transitions. (In image processing you find edges by taking the squared gradient (i.e., high-pass filter) and then keep only the pixels along locally-maximal ridges.) $\endgroup$ – Wandering Logic Aug 28 '13 at 13:18
7
$\begingroup$

A high pass filter will remove a large portion to all of the 0 Hz component or DC offset from a signal. That's similar to subtracting the mean average, which for a normally distributed signal will make around half of the signal negative (since it was below the original average mean).

If you want the mean to be the same after a high pass filter, you could always add it back.

If you don't care about the actual mean value, you could also add an arbitrarily large positive offset to make sure the sum was always positive.

$\endgroup$
3
  • $\begingroup$ Do you suggest I add the mean of the original data to the high-pass filtered results? I tried that, and it may not necessarily result in positive real. In other words, the negative values in HPF results are comparable to the mean value in the case I am looking at. $\endgroup$ – Sidhha Aug 28 '13 at 8:01
  • 1
    $\begingroup$ What's wrong with negative values? I appreciate you're looking at "energy" and as such a negative quantity is a bit counter-intuitive, but in performing this filtering operation you are explicitly removing the DC offset. It is then perfectly normal for a signal to have positive and negative excursions. $\endgroup$ – Speedy Aug 28 '13 at 10:49
  • $\begingroup$ The problem surfaces when I switch to band pass filter because the negative components are relatively large and they contaminate the results completely which is definitely not what one would expect. I then observed it was occurring due to HPF and hence, the question I asked. $\endgroup$ – Sidhha Aug 28 '13 at 12:44
0
$\begingroup$

You can try to perform a band-pass filter instead, between some value very near to 0 (very large period of the sinusoidal) and your current cutoff frequency.

$\endgroup$

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.